正常数组排序 升序 sort(a,a+n);//从下标0到n-1 sort(a+1,a+1+n)//从下标1到n 降序 sort(a+1,a+n+1,greater<int>());//从下标1到n 结构体排序 //先创一个结构体 #define N 10; struct eee{ int x;int y; }a[N]; #include <algorithm> sort(a,a+N,cmp); //自定义cmp bool cmp(eee a,eee b) { return a.x>b.x; }