Advertisement
denis_adamchuk

Untitled

Nov 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4. #include <algorithm>
  5. #include <numeric>
  6.  
  7. std::vector<std::pair<int, int>> gc_integers = { { 1, 2 }, { 3, 1 } };
  8.  
  9. int main()
  10. {
  11.     auto m = std::reduce(gc_integers.begin(), gc_integers.end(), std::make_pair<int, int>(0, 0),
  12.         [](const auto& max, const auto& current)
  13.         {
  14.             return std::make_pair(
  15.                 std::max(max.first, current.first),
  16.                 std::max(max.second, current.second));
  17.         });
  18.     std::cout << "first max = " << m.first << " second max = " << m.second << std::endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement