The following code defines a pair of functions which could be incorporated into applications wishing to ensure that the same sequence of numbers is generated across different machines:
下面的代码,在种子值相同的情况下,即使是在不同的机器上也可以产生相同的序列值
static unsigned long int next = 1;
int myrand(void) /* RAND_MAX assumed to be 32767 */
{
next = next * 1103515245 + 12345;
return((unsigned int)(next/65536) % 32768);
}
void mysrand(unsigned int seed)
{
next = seed;
}
详见