Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- bool compare(int a, int b) {
- return a > b;
- }
- int main() {
- std::vector<int> ints = {1, 4, 3, 2, 6, 3};
- auto lambda = [](int a, int b){
- return a > b;
- };
- //std::sort(ints.begin(), ints.end(), lambda);
- std::sort(ints.begin(), ints.end(), compare);
- for (const auto x : ints) {
- std::cout << x << ' ';
- }
- std::cout << "\n\n";
- std::vector<std::string> strings = {"ala", "ma", "kota"};
- auto printer_lambda = [](const std::string& str) {
- std::cout << str << ' ';
- };
- std::for_each(strings.begin(), strings.end(), printer_lambda);
- printer_lambda("dodatkowe!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement