class Ge
{
public:
bool operator()(int val)
{
return val > 5;
}
};
void test03()
{
vector<int>v;
for (int i = 0; i < 10; i++)
{
v.push_back(i);
}
vector<int>::iterator it = find_if(v.begin(), v.end(), Ge());
if (it == v.end())
{
cout << "未找到" << endl;
}
else
{
cout << "找到了" << *it << endl;
}
}
class Ge
{
public:
bool operator()(int val)
{
return val > 5;
}
};
class Mycopmare
{
public:
bool operator()(int val1, int val2)
{
return val1 > val2;
}
};
void test04()
{
vector<int>v;
v.push_back(10);
v.push_back(90);
v.push_back(70);
v.push_back(20);
v.push_back(40);
sort(v.begin(), v.end());
for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
{
cout << *it << " ";
}
cout << endl;
sort(v.begin(), v.end(), Mycopmare());
cout << "--------------" << endl;
for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
{
cout << *it << " ";
}
cout << endl;
}