NO8——排序

 1 //sort
 2 #include<algorithm>
 3 bool cmp(const int a,const int b)
 4 {
 5     return a>b;//降序排列
 6 }
 7 
 8 //qsort
 9 #include <stdlib>
10 int cmp(const void *x,const void *y)
11 {
12     return (*(int*)x-*(int*)y);//升序
13 }
14 qsort(s,n,sizeof(s[0]),cmp);//调用

 

posted @ 2017-08-08 10:52  GGBeng  阅读(130)  评论(0编辑  收藏  举报