O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.3.5. Mathematical Algorithms

Figure 16.5 demonstrates several common mathematical algorithms, including random_shuffle, count, count_if, min_element, max_element, minmax_element, accumulate, for_each and transform.

 1   // Fig. 16.5: fig16_05.cpp 2   // Mathematical algorithms of the Standard Library. 3   #include <iostream> 4   #include <algorithm> // algorithm definitions 5   #include <numeric> // accumulate is defined here  6   #include <array> 7   #include <iterator> 8   using namespace std; 9 10   bool greater9( int ); // predicate function prototype11   void outputSquare( int ); // output square of a value12   int calculateCube( int ); // calculate cube of a value13 14   int main()15   {16      const size_t ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required