C++ examples for STL Algorithm:min
The following code demonstrates min and max for int and char values.
#include <iostream> #include <algorithm> using namespace std; int main() //from w w w . j ava2s . c om { cout << "The minimum of 12 and 7 is: " << min( 12, 7 ); cout << "\nThe maximum of 12 and 7 is: " << max( 12, 7 ); cout << "\nThe minimum of 'G' and 'Z' is: " << min( 'G', 'Z' ); cout << "\nThe maximum of 'G' and 'Z' is: " << max( 'G', 'Z' ); cout << endl; }