标签:cst 需要 srand 编程资料 name 付费 stream and return
小学生c++编程资料
链接:https://pan.baidu.com/s/1FfOirxJ9rrY7rxtHUM4W_A
提取码:uqm9
#include<iostream>
#include<ctime> //需要调用time()函数
#include<cstdlib> //需要调用srand()和rand()函数
using namespace std;
int main()
{
int n,a;
cout<<"抽奖程序"<<endl;
cout<<"请输入1-5:";
cin>>n;
srand(time(0)); //随机种子
a=rand()%5+1; //随机产生1至5的整数
if(n==a)
cout<<"恭喜您,中奖了!奖金10元"<<endl;
else
cout<<"没中奖,请付费2元" <<endl;
cout<<"中奖号码是"<<a<<endl;
return 0;
}
标签:cst 需要 srand 编程资料 name 付费 stream and return
原文地址:https://www.cnblogs.com/kixiaoyuan/p/12694997.html