69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i;
srand((unsigned int) time(0));
/*如果把srand()函数写在for循环里,就出一样的数,为什么呢?*/
for (i = 0; i < 100; i++)
printf("%d ",rand());
return 0;
}
srand((unsigned int) time(0));
for (i = 0; i < 100; i++){
for(j=0; j<300; ++j)
for(k=0; k<200000; ++k);
printf("%d ",rand());
}
srand((unsigned int) time(0));
for (i = 0; i < 100; i++)
printf("%d ",rand());
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i,j,k;
for (i = 0; i < 100; i++){
for(j=0; j<300; ++j)
for(k=0; k<200000; ++k);
srand((unsigned int) time(0));
printf("%d ",rand());
}
return 0;
}