使用qsort()函数排序 #define n 100; int a[n]; int cmp(const void*x,const void*y){ return *(int *)x-*(int *)y; } qsort(a,n,sizeof(int),cmp);