STL: Algorithm: generate ()


#include
#include
using namespace std;

int main ()
{
vector v (10);
// allocate space for 10 elements

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

for ( size_t i = 0; i < v.size (); i++ ) printf ("%d\n", v [i]); return 0; } /* output 41 18467 6334 26500 19169 15724 11478 29358 26962 24464 Process returned 0 (0x0) execution time : 0.031 s Press any key to continue. */ [/sourcecode]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s