当前位置: 代码迷 >> 综合 >> 输出随机数
  详细解决方案

输出随机数

热度:23   发布时间:2024-01-22 04:45:48.0

 

 

 

 

#include<iostream>
#include<ctime>
using namespace std;
int main(void)
{
int i,ran_num;
srand(time(0));
ran_num=rand()%1001;
cout<<"输出一个随机数:"<<ran_num<<endl;
cout<<"输出一百个随机数:"<<endl;
for(i=0;i<100;i++)
{
ran_num=rand()%1001;
cout<<ran_num<<endl;
}
return 0;
}


 

  相关解决方案