1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <vector> #include <algorithm> #include <iostream>
int main() { std::vector<int> values = {9,4,56,32,34};
std::sort(values.begin(), values.end()); for (int value : values) std::cout << value << std::endl;
std::cout << std::endl;
std::sort(values.begin(), values.end(), [](int a, int b){ return a > b; }); for (int value : values) std::cout << value << std::endl;
return 0; }
|