#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main(int argc, char** argv) { int a,n; bool s=false; cout<<"抽奖程序"<<endl<<"请输入一个1-5的数"<<endl; cin>>n; srand(time(0)); a=rand()%5+1; if(n==a){ s=true; } switch(s){ case false:cout<<"恭喜你没中奖"<<endl;break; case true:cout<<"恭喜你中奖了"<<endl;break; } system("pause"); return 0; }