读书人

c++ STL中用来排序的自定义比较函数的

发布时间: 2012-03-08 13:30:13 作者: rapoo

c++ STL中用来排序的自定义比较函数的机制是什么
如将容器中的整形值按降序排列

bool camp(const int &a,const int &b)
{
if(a!=b) return a>b;
else return a>b;
}
. . . .

sort(v.begin(),v.end(),camp);

我是新手,望高手详细指导,感谢!

[解决办法]
camp不对啊。逻辑不对。
[解决办法]

C/C++ code
bool comp(const int &a,const int &b){    return a>b;} 

读书人网 >C++

热点推荐