首先看三段代码
代码一:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int a = 0, b = 0, c = 0;
srand((unsigned)time(NULL));
a = rand();
/*srand((unsigned)time(NULL));*/
b = rand();
c = rand();
printf("%d %d %d\n", a, b,c);
return 0;
}
代码二:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int a = 0, b = 0, c = 0, d = 0;
srand((unsigned)time(NULL));
a = rand();
b = rand();
printf("%d %d\n", a, b);
srand((unsigned)time(NULL));//比第一段代码增加了一条srand函数
c = rand();
d = rand();
printf("%d %d\n", c, d);
return 0;
}
代码三:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int a = 0;
for (int i = 0;i <