#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"欢迎来到猜数游戏!猜不对就会死哦!\n";
cout<<"请输入猜数范围:";
int a,b,sum=0,shu,cishu;
scanf("%d-%d",&a,&b);
cout<<"你要猜几次:";
scanf("%d",&cishu);
srand(time(0));
int zhun=rand()%(b-a+1)+a;
while(1){
cout<<"请输入你猜的数:";
cin>>shu;
if(shu>zhun){
sum++;
cout<<"猜大了!"<<endl;
cishu--;
if(cishu!=0) printf("你还能猜%d次。\n",cishu);
else printf("你没机会了哦~~~\n",cishu);
}
if(shu<zhun){
sum++;
cout<<"猜小了!"<<endl;
cishu--;
if(cishu!=0) printf("你还能猜%d次。\n",cishu);
else printf("你没机会了哦~~~\n",cishu);
}
if(shu==zhun){
sum++;
cout<<"恭喜你猜对了,你用的次数为:"<<sum<<"次\n";
cout<<"期待你下一次的表现!";
break;
}
if(cishu==0){
cout<<"先让你死个明白,答案是"<<zhun<<endl;
cout<<"去死吧!";
break;
}
}
return 0;
}
猜数游戏升级版
最新推荐文章于 2024-07-10 22:29:37 发布