- 游戏
猜数字游戏
- 2021-9-18 23:35:35 @
普通猜数字,还行吧。
#include <bits/stdc++.h>
using namespace std;
void Eazy(){
int a=rand()%99+1;
while(true){
cout<<"This is a number in 1 to 100."<<endl<<"Guess it:";
int h;
cin>>h;
if(h==a){
cout<<"Congratulations!"<<endl;
break;
}else if(h<a){
cout<<"Sorry,you guess are small."<<endl;
}else if(h>a){
cout<<"Sorry,you guess are big."<<endl;
}
}
}
void Normal(){
int a=rand()%999+1;
while(true){
cout<<"This is a number in 1 to 1000."<<endl<<"Guess it:";
int h;
cin>>h;
if(h==a){
cout<<"Congratulations!"<<endl;
break;
}else if(h<a){
cout<<"Sorry,you guess are small."<<endl;
}else if(h>a){
cout<<"Sorry,you guess are big."<<endl;
}
}
}
void Hard(){
int a=rand()%9999+1;
while(true){
cout<<"This is a number in 1 to 10000."<<endl<<"Guess it:";
int h;
cin>>h;
if(h==a){
cout<<"Congratulations!"<<endl;
break;
}else if(h<a){
cout<<"Sorry,you guess are small."<<endl;
}else if(h>a){
cout<<"Sorry,you guess are big."<<endl;
}
}
}
int main(){
srand(time(0));
while(true){
cout<<"Guess number!"<<endl<<"1) Eazy"<<endl<<"2) Normal"<<endl<<"3) Hard"<<endl<<"4) Exit"<<endl<<"Please select(1-4):";
int h;
cin>>h;
if(h<1 || h>4) cout<<"Incorrect input!"<<endl;
else{
if(h==1) Eazy();
else if(h==2) Normal();
else if(h==3) Hard();
else break;
}
}
return 0;
}
5 条评论
-
HhF03 LV 4 @ 2022-12-28 19:08:52
devc艹有自带的项目jackpot
-
2022-12-26 18:52:00@
厉害
-
2022-11-20 18:49:21@
nb
-
2021-10-11 17:10:24@
"Eazy" 难道不是Easy吗
-
2021-9-22 22:19:26@
qp
- 1