#include <stdio.h>
#include <stdlib.h>
int num[12] = {
14, 5, 9, 7, 6, 0, 91, 4, 1, 3, 2, 8
};
int comp(const void *, const void *);
int main(int argc, char *argv[])
{
int i;
printf("Original array: ");
for(i = 0; i < 12; i++)
printf("%d,", num[i]);
printf("\n");
qsort(num, 12, sizeof(int), comp);
printf("Sorted array: ");
for(i = 0; i < 12; i++)
printf("%d,", num[i]);
printf("\n");
system("pause");
return 0;
}
int comp(const void *i, const void *j)
{
return *(int *)i - *(int *)j;
}
|