Re: pass time(0) to srand() when generating random numbers.
From: Andreas Kahari (ak+usenet_at_freeshell.org)
Date: 10/31/03
- Next message: Christian Bau: "Re: Interview question !!!"
- Previous message: Jeremy Yallop: "Re: Interview question !!!"
- In reply to: Intaek LIM: "pass time(0) to srand() when generating random numbers."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 31 Oct 2003 09:02:42 +0000 (UTC)
In article <d93e2a33.0310310045.575d3fb9@posting.google.com>, Intaek LIM wrote:
[cut]
> // seed is the return value for time(0)
> // i wrote it by my hand. :-(
> int seed = 1067589554;
> srand(seed);
The time() function returns a value that represents the current
time. Seeding the pseudo random generator with time(0) will
ensures that you get a different pseudo random list of numbers
each time you run the program.
Hard coding the seed ("1067589554" in your code) ensures that
you get the *same* pseudo random list of numbers each time you
run your program.
-- Andreas Kähäri
- Next message: Christian Bau: "Re: Interview question !!!"
- Previous message: Jeremy Yallop: "Re: Interview question !!!"
- In reply to: Intaek LIM: "pass time(0) to srand() when generating random numbers."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|