C++ 的 sort() 函数

头文件<algorithm>

sort(begin, end, cmp)

1.其中begin为指向待sort()的数组的第一个元素的指针,end为指向待sort()的数组的最后一个元素的下一个位置的指针。sort(a,a+n);

2.cmp参数为排序准则,如果没有的话,默认以升序排序。

3.降序cmp参数

bool cmp(int a,int b)
{
    return a>b;
}
原文地址:https://www.cnblogs.com/When6/p/11945107.html