lambda表达式
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> vec{ 1,2,3,4,3,2,6,4,7,8 };
sort(vec.begin(), vec.end(), [](int a, int b)->bool {
return a > b;
});
for (auto num : vec) {
cout << num << " ";
}
cout << endl;
system("PAUSE");
return 0;
}
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> vec{ 1,2,3,4,3,2,6,4,7,8 };
sort(vec.begin(), vec.end(), [](int a, int b)->bool {
return a > b;
});
for (auto num : vec) {
cout << num << " ";
}
cout << endl;
system("PAUSE");
return 0;
}