#include
#include
#define max 10
void print_array(int *array) {
int x;
for(x = 0; x
printf("%d, ", array[x]);
else
printf("%d\n", array[x]);
}
}
void main(){
int iarray[max];
int i,j;
int temp;
int min;
// Seed rand()
srand((unsigned int)time(NULL));
for(i = 0; i < max; i++)
iarray[i] = (int)(rand() % 100);
//selection sort
for(i=0 ; i
print_array(iarray);
min = i;
for(j=i+1;j
temp = iarray[i];
iarray[i] = iarray[min];
iarray[min]=temp;
}
printf("result sort\n");
print_array(iarray);
}
No comments:
Post a Comment