如何创建一组对,其中的元素(对)使用自定义bool函数进行排序?我写
set <pair<int,int>,compare> myset;
Run Code Online (Sandbox Code Playgroud)
并得到错误:参数2处的类型/值不匹配,预期类型,得到"比较"
我把"比较"定义为
bool compare(pair <int,int> g1, pair <int,int> g2)
{
return (g1.second-g1.first > g2.second-g2.first);
}
Run Code Online (Sandbox Code Playgroud)
而且当然
#include <vector>
#include <set>
Run Code Online (Sandbox Code Playgroud)