C语言库qsort()函数

#include <stdio.h>
#include <stdlib.h>

int values[] = { 88, 56, 100, 2, 25 };

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main () {
   int n;

   printf(Before sorting the list is: \n);
   for( n = 0 ; n < 5; n++ ) {
      printf(%d , values[n]);
   }

   qsort(values, 5, sizeof(int), cmpfunc);
   printf(\nAfter sorting the list is: \n);

   for( n = 0 ; n < 5; n++ ) {   
      printf(%d , values[n]);
   }

   return(0);
}

相关文章

for遍历数组
。。。
声明一个计数循环
咕咕咕
#include <stdio.h> int main (void) { printf (&quo...