#include <algorithm>
bool camp(const int& a, const int&b)
{
return a > b;
}
在函数中如果数组为A,大小为size。
sort(A,A+size,camp);
那么久完成了从大到小的排序。如果从小到大改变camp中的符号即可。
#include <algorithm>
bool camp(const int& a, const int&b)
{
return a > b;
}
在函数中如果数组为A,大小为size。
sort(A,A+size,camp);
那么久完成了从大到小的排序。如果从小到大改变camp中的符号即可。