<小牛蛙游戏集>猜数字游戏
Void_Trailwalker
·
·
休闲·娱乐
#include<bits/stdc++.h>
using namespace std;
int main(){
srand((unsigned int)time(NULL));
cout << "猜数字游戏开始!\n";
T:
cout << "输入数据范围:";
int m;
cin >> m;
cout << "\n";
m += 1;
int n = rand()%m;
int num;
cout << "输入次数:";
cin >> num;
cout << "------------------------------------------------------------------------------------------------------------------------";
int t;
for(int i=1;i<=num;i++){
cout << "输入你的答案:";
cin >> t;
if(t==n){
cout << "你赢了!\n是(1)否(0)再来一局?";
cin >> t;
if(t){
cout << "------------------------------------------------------------------------------------------------------------------------";
goto T;
}else{
return 0;
}
}
else if(t>n){
cout << "大了\n";
}else{
cout << "小了\n";
}
cout << "------------------------------------------------------------------------------------------------------------------------";
}
cout << "哈哈哈!正确答案是" << n;
cout << "\n是(1)否(0)再来一局?";
cin >> t;
if(t){
goto T;
}else{
return 0;
}
}