(ps:sort函数的头文件为#include <algorithm>) 想把整数数组按降序排列,可以先定义一个比较函数cmp bool cmp(int a,int b) { return a>b; } 排序的时候就写sort(a,a+100,cmp);