16.3.13. min, max, minmax and minmax_element

Figure 16.13 demonstrates algorithms min, max, minmax and minmax_element.

 1   // Fig. 16.13: fig16_13.cpp 2   // Algorithms min, max, minmax and minmax_element. 3   #include <iostream> 4   #include <array> 5   #include <algorithm> 6   using namespace std; 7  8   int main() 9   {10      cout << "The minimum of 12 and 7 is: " << min( 12, 7 );11      cout << "\nThe maximum of 12 and 7 is: " << max( 12, 7 );12      cout << "\nThe minimum of 'G' and 'Z' is: " << min( 'G', 'Z' );13      cout << "\nThe maximum of 'G' and 'Z' is: " << max( 'G', 'Z' );14 15      // determine which argument is the min and which is the max16      auto result1 = minmax( 12, 7 );17      cout << ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.