minmax_element c++ code example
Example: minmax_element c++
// minmax_element
#include // std::cout
#include // std::minmax_element
#include // std::array
int main () {
std::array foo {3,7,2,9,5,8,6};
auto result = std::minmax_element (foo.begin(),foo.end());
// print result:
std::cout << "min is " << *result.first;
std::cout << ", at position " << (result.first-foo.begin()) << '\n';
std::cout << "max is " << *result.second;
std::cout << ", at position " << (result.second-foo.begin()) << '\n';
return 0;
}