«

c++语言编程 10号-198号随机抽奖

点亮灯 发布于 阅读:32 C++


c++语言编程 10号~198号随机抽奖

#include<iostream>  //引入iostream库,才能使用输入输出流,cin和cout
#include<cstdlib>   //工具函数,包括内存管理、随机数生成、程序控制等
#include<ctime>     //提供与时间相关的函数和类型

using namespace std;    //引入 std 命名空间

int main()
{
    //定义变量

    int shu1;

//录入数据
srand(time(0));
shu1=rand()%(198-10+1)+10;

cout<<"请按回车键开始抽奖(10号~198号)";
cin.get();          //回车键继续运行程序
cout<<endl;
cout<<"恭喜"<<shu1<<"号中奖了"<<endl;

}