#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main( void )
{
// 使随机数和时间绑定~所以每次的数字会不一样~
srand( (unsigned)time( NULL ) );
for(int i=0;i<50;++i)
printf("%d/n", rand());
return 0;
}
#include <stdio.h>
#include <time.h>
int main( void )
{
// 使随机数和时间绑定~所以每次的数字会不一样~
srand( (unsigned)time( NULL ) );
for(int i=0;i<50;++i)
printf("%d/n", rand());
return 0;
}
此博客展示了一段C语言代码,通过包含<stdlib.h>、<stdio.h>、<time.h>头文件,使用srand和rand函数,将随机数与时间绑定,实现了生成50个随机数并打印输出的功能。
1597

被折叠的 条评论
为什么被折叠?



