#include <stdio.h> #include <stdlib.h> #include <time.h> static unsigned long int next = 1; unsigned int rand0(); void srand1(unsigned int seed); int main() { int count; unsigned int seed; while(scanf("%u",&seed)==1) { srand1(seed); //可用变化的时间来做种子 //srand1((unsigned int)time(0)); for(count=0;count<5;count++) { printf("%d ",rand0()); } } return 0; } unsigned int rand0() { next = next * 1103515245 + 12345; return (unsigned int)(next / 65536)%32768; } void srand1(unsigned int seed) { next = seed; }