标签:clu bool iostream space sort tor char ios bsp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(int a, int b)
{
return a >= b;
}
int main(int argc, char *argv[])
{
vector<int> vec;
for (int i = 0; i < 17; i++)
{
int x = 0;
vec.push_back(x);
}
sort(vec.begin(), vec.end(), compare);
return 0;
}
compare必须针对相等返回false, 显然, 上面程序中, 当a和b相等时, compare返回了true, 这是有问题的
标签:clu bool iostream space sort tor char ios bsp
原文地址:https://www.cnblogs.com/wangshaowei/p/10268488.html