首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++ STL中用来排序的自定义比较函数的机制是什么,该如何解决

2012-03-08 
c++ STL中用来排序的自定义比较函数的机制是什么如将容器中的整形值按降序排列bool camp(const int &a,con

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;} 

热点排行