bool cmp(int a, int b){ return a>b; //由大到小 降序 } bool cmp(int a, int b){ return a<b; //由小到大 升序 }sort(s,s+n,cmp);