IOS: srand () and rand (), iossrandrand
Srand (seed) is used to set the starting point of a random sequence to seedsrand (int) time (0), which indicates that the int value corresponding to the current time is the starting point of the random sequence, so that each program runs, the time function of different random numbers can be obtained because of different starting points. The time function provides the number of seconds since 00:00:00, January 1, January 1, 1970. It must contain a parameter to store this number of seconds. time () may cause syntax errors, time (0) indicates that the storage is not performed in seconds.
00:00:00 is actually ----> the program developer wrote the first draft in X for the unix C language, so this zero point is set. The popularity of computers and PCs is also a concern after 1970s. So, don't worry about why it starts at this point in time.
Srand (int) time (0); // In fact, the random number generated by rand is always different.
Srand (time (0); // set the seed first
Rand (); // then generate a random number
Srand is the number of random seeds. Each time you plant a different seed, the random number obtained using Rand is different. Time (0) is used to get the current Time value (because the Time is different every moment) for each different seed ).
Srand (time (0 ));
It is to give this algorithm a startup seed, that is, the random seed number of the algorithm. Only after this number is available can random numbers be generated,
Initialize the random number seed in seconds from 1970.1.1 to the present.