#include <stdlib.h>
#include <iostream.h>
#include <time.h>
#include <WINDOWS.H>
void main()
{
int base = 100;
srand(time(NULL));
for (int i=0;i<100;i++)
{
int a=rand()%base;
system("cls");
Sleep(1000);
cout<<a<<endl;
Sleep(1000);
}
}
#include <iostream.h>
#include <time.h>
#include <WINDOWS.H>
void main()
{
int base = 100;
srand(time(NULL));
for (int i=0;i<100;i++)
{
int a=rand()%base;
system("cls");
Sleep(1000);
cout<<a<<endl;
Sleep(1000);
}
}
本博客展示了使用C++编程语言通过srand和rand函数生成随机数,并利用system和Sleep函数实现每秒输出一个随机数的过程。
1万+

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



