minmax element c 2b 2b

Solutions on MaxInterview for minmax element c 2b 2b by the best coders in the world

showing results for - "minmax element c 2b 2b"
Facundo
10 Mar 2018
1// minmax_element
2#include <iostream>     // std::cout
3#include <algorithm>    // std::minmax_element
4#include <array>        // std::array
5
6int main () {
7  std::array<int,7> foo {3,7,2,9,5,8,6};
8
9  auto result = std::minmax_element (foo.begin(),foo.end());
10
11  // print result:
12  std::cout << "min is " << *result.first;
13  std::cout << ", at position " << (result.first-foo.begin()) << '\n';
14  std::cout << "max is " << *result.second;
15  std::cout << ", at position " << (result.second-foo.begin()) << '\n';
16
17  return 0;
18}
19