Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::generate

 

Algorithm.

 

#include <algorith>
#include <iostream>
#include <iterator>
#include <vector>

int main()
{
  const int size = 20;
  std::vector<int> v(size);

  //Generate the random numbers
  std::generate(v.begin(), v.end(), std::rand);

  //Output on screen
  std::copy(v.begin(),v.end(), std::ostream_iterator<int>(std::cout, "\n"));
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict