0
What is seed value why it is used??
2 Antworten
+ 3
Seed value if passed to srand() to generate a random number using the seed. Now to generate a unique random number each time you can take the time as seed value because it keeps changing. thus you can do srand(time(0)).
0
"This number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called. This algorithm uses a seed to generate the series, which should be initialized to some distinctive value using function srand." (cplusplus.com)... Essentially, it is like saying "what is x + 3?" If we define x to be 1, then we have a definitive answer of 4. If x remains undefined, we cannot get an answer. Thus, by providing a seed, the algorithm can generate series of numbers as an output for rand(). If we do not provide a seed, then it will not have a defined path. Also, make sure to define a new seed every time, or you may get repeated random numbers.