STL algorithms
The std::max
and std::min
functions return the maximum and minimum argument respectively.
There are two versions of the functions:
std::max(a, b)
version, which receives two arguments.std::max({a, b, ..., z})
version, which receives two or more arguments enclosed within an initializer list.std::max and std::min are more concise than using if-else or a ternary operator, especially for more than two elements.
Write a program which receives three integers and prints out the maximum and minimum in a line each.
std::cin >> a >> b >> c
.std::max({a, b, c})
and std::min({a, b, c})
and print them out.