Fill list with random numbers with generate function : list insert « List « C++






Fill list with random numbers with generate function

  
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <list>

using namespace std;

int main( )
{
   list<int> data( 100000 );

   // create random numbers
   generate( data.begin(), data.end(), rand );

}
  
    
  








Related examples in the same category

1.Insert elements of array into a list
2.Combine insert and begin to add element to the start of a list
3.Combine insert and end to add elements to the end of a list
4.Initialize a list with values in a vector
5.Move position pointer and insert again