c ++ rand () and srand () supplement

 

 After the first srand (time (0)) rand () generates a series of random numbers, cycle sequentially taken first, second ......

A case where a program execution time of less than 1s, and the second at srand () to generate a series of the same with the first number.

Also, the second at srand () Let rand given again from the first number, then start the second cycle and from 2275

 

So the srand () function on the inside, and the cycle is called the function, every time the start removed from the first number,

The srand () in the main function, can turn out

Guess you like

Origin www.cnblogs.com/li-lou/p/12391859.html