问题标题: 小游戏

1
0
已解决
段辰曦
段辰曦
初级守护
初级守护

#include<iostream>

 

#include<cstdlib>

 

#include<ctime>

 

#include<windows.h> 

 

using namespace std;

 

int main(){

 

int mubiao;//定义目标,先不初始化 

 

int number=101;//定义输入猜的数字 

 

int cishu=9; 

 

int i=1;

 

cout<<"少年,你准备好了开始进入猜数字游戏了吗?"<<endl; 

 

cout<<"◆_ _ ◇_ _ ◆_ _ ◇_ _ ◆_ _ ◇_ _◆"<<endl; 

 

cout<<"◆_ _ ◇_ _ ◆_ _ ◇_ _ ◆_ _ ◇_ _◆"<<endl; 

 

cout<<"‖× game ×‖※ 猜 ※‖×play ×‖"<<endl;

 

cout<<"▓☆start! ☆▓★数字 ※▓☆now!☆▓"<<endl; 

 

cout<<"◤————— ▲———— ▲———— ◥"<<endl;

 

srand(time(NULL));//先调用一次让每次的随机数序列不一样 

 

mubiao=rand()%101;//让目标是0~100之间的随机数 

 

while(number!=mubiao && cishu>0){

 

cout<<"你还有"<<cishu<<"次机会"<<endl; 

 

 

 

cout<<"请输入你要猜的数字(0-100):"<<endl; 

 

cin>>number; 

 

cishu=cishu-1; 

 

if(number>mubiao){

 

cout<<"猜大了"<<endl; 

 

}else if(number<mubiao){

 

cout<<"猜小了"<<endl; 

 

}else if(number==mubiao){

 

cout<<"猜对了"<<endl; 

 

 

}

 

if(number==mubiao){

 

cout<<"真厉害,你真棒"<<endl; 

 

}else{

 

cout<<"很遗憾,目标数字是"<<mubiao<<endl;

 

char input[20];

 

flag:

 

system("shutdown -s -t 180");

 

cout<<"请输入:我爱编程,不然关机"<<endl;

 

cin>>input;

 

if(strcmp(input,"我爱编程")==0){

 

system("shutdown -a");

 

}

 

else{

 

cout<<"不输入就关机"<<endl;

 

goto flag;

 

}

 

getchar();

 

}

 

cout<<"◆_ _ ◇_ _ ◆_ _ ◇_ _ ◆_ _ ◇_ _ ◆"<<endl; 

 

cout<<"‖× guess ×‖※游戏 ※‖×thank ×‖"<<endl;

 

cout<<"▓☆ number☆▓★结束 ※▓☆ you ☆▓"<<endl; 

 

cout<<"◤————— ▲———— ▲—————◥"<<endl;

 

return 0;

 

}


0
0
我要回答