C++小游戏

大家好!今天为大家带来一个使用for语句的小游戏!

代码如下:

#include<iostream> #include<cstdlib> #include<ctime> #include<Windows.h> using namespace std; int main() { int a,b,jq=1000,j,s; cx: cout<<"-------------------------------"<<endl; cout<<" 抽奖系统"<<endl; cout<<" "<<endl; cout<<" "<<endl; cout<<" ———————————————"<<endl; cout<<" |你现有金额是:"; if(jq>=1000) cout<<jq<<" |"<<endl; else cout<<jq<<" |"<<endl; cout<<" |一百块一次,赢了得一千!!!|"<<endl; cout<<" ———————————————"<<endl; cout<<" "<<endl; cout<<"-------------------------------"<<endl; cout<<"1.START"<<endl; cout<<"2.OVER"<<endl; cout<<"请输入:"; cin>>j; system("cls"); if(j==1) { cx2: cout<<"你现有金额是:"; if(jq>=1000) cout<<jq<<endl; else cout<<jq<<endl; cout<<"请输入1~100的数字:"; cin>>a; srand(time(0)); b=rand()%(100-1+1)+1; if(a==b) { system("cls"); cout<<"恭喜你,中奖1000元"<<endl<<endl; cout<<"要再来吗?"<<endl; cout<<"1.要"<<endl; cout<<"2.不要"<<endl; jq+=900; cin>>s; if(s==1) { if(jq>=100) { system("cls"); goto cx2; } if(jq==0) { cout<<"余额不足!"<<endl; Sleep(1000); cout<< "重开吧!"<<endl; Sleep(1000); cout<<"孩子!"<<endl; Sleep(1200); cout<<"菜就多练!!!"<<endl; } } else { cout<<"再见!"; return 0; } } else { system("cls"); cout<<"没中奖,中奖号码是:"<<b<<endl; cout<<"你的号码是:"<<a<<endl<<endl; cout<<"要再来吗?"<<endl; cout<<"1.要"<<endl; cout<<"2.不要"<<endl; jq-=100; cin>>s; if(s==1) { if(jq>=100) { system("cls"); goto cx2; } if(jq==0) { cout<<"余额不足!"<<endl; Sleep(1000); cout<< "重开吧!"<<endl; Sleep(1000); cout<<"孩子!"<<endl; Sleep(1200); cout<<"菜就多练!!!"<<endl; } } else { cout<<"再见!"; return 0; } } } if(j==2) { cout<<"再见!"; return 0; } }

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值