Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
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")); }