初级光能
#include <bits/stdc++.h>
using namespace std;
int main(){
a1:system("cls");
system("color 8E");
cout<<"--------------------猜数游戏--------------------"<<endl;
cout<<" 键入1直接开始"<<endl;
cout<<" 键入2游戏规则"<<endl;
int jianru;
cin>>jianru;
if (jianru==2){
cout<<"1,不告诉你";
goto a1;
}
else if (jianru==1){
cout<<"那好,我们开始吧!";
goto start;
}
start:system("cls");
cout<<"猜一个数:";
srand(time(NULL));
int gesnumberplayer,gesnumber,gesnumbergessum;
gesnumber=rand();
cout<<"猜数范围:0到1000"<<endl;
while (1){
cin>>gesnumberplayer;
if(gesnumberplayer==gesnumber){
cout<<"你真棒!用了"<<gesnumbergessum<<"次就猜对了";
return 0;
}
else if(gesnumberplayer!=gesnumber){
if (gesnumberplayer>gesnumber){
cout<<"小一点\n";
}
else if (gesnumberplayer<gesnumber){
cout<<"大一点\n";
}
gesnumbergessum++;
}
}
return 0;
}