Ordarray
ordarray.c#include <stdio.h>
int chkar(int *aip){
for(; *(aip+1) != 0; aip++){
if(*aip > *(aip+1))
return(1);
}
return(0);
}
void ord(int *aip){
int tmp;
for(; *(aip+1) != 0; aip++){
if(*aip > *(aip+1)){
tmp = *aip;
*aip = *(aip+1);
*(aip+1) = tmp;
}
}
}
void ordar(int *aip){
while(chkar(aip))
ord(aip);
}
int main(){
int ari[] = {2,3,7,9,4,1,5,8,6,0};
int *pi;
ordar(ari);
for(pi = ari;*pi != 0; pi++)
printf("%d, ", *pi);
putchar('\n');
return(0);
}
OUTPUT:
1, 2, 3, 4, 5, 6, 7, 8, 9,