NT rand (void);
Returns a random number 0 ~ Pow (2, sizeof (int))-1
long int random (void);
Returns a random number 0 ~ Pow (2, sizeof (long int))-1
void Srand (unsigned int seed);
Set the seed of the RAND function
void srandom (unsigned int seed);
Set the seed of the random function
Attention:
The difference between 1.rand and random is that the return type is different, int and long int (although the effect is the same on a normal 32-bit machine)
2. Before using Rand or random, use time (0) Getpid () to set random seeds. Otherwise, the default seed is 1, and the random number generated is the same.
3.rand (void) and srand (unsigned int seed) are used in conjunction with random (void) and srandom (unsigned int seed).
Ps:
The probability of generating a repeating random number using Rand or random is as follows:
100,000-----of 3
1 million-----of 230
10 million----of 23,000
Thus, the probability of repetition as the number increases is becoming more and more rapid.
The rand () and random () functions in C/