+ 3
C++
what is the rule of srand in rand numbers ?
2 Antworten
+ 2
srand sets a new seed for the pseudo random number generator. A seed means is like a start value. If you don't change the seed, rand might return always the same values
+ 1
srand() uses its argument seed as a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to rand(). If srand() is not called, the rand() seed is set as if srand(1) was called at program start. Any other value for seed sets the generator to a different starting point. The rand() function generates pseudo-random numbers.