话不多说,直接上代码!
#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
using namespace std;
char s;
char gxia='A',choose;
int rand1,numn;
bool flag=true;
int cishu=0;
void menu()
{
system("color 3D");
cout<<setw(80)<<"猜数字1.5"<<endl;
cout<<setw(80)<<"A.开始游戏"<<endl;
cout<<setw(80)<<" B.帮助"<<endl;
cout<<setw(80)<<"C.退出游戏"<<endl;
do {
s=getch();
} while(s<'A'||s>'C');
}
void nac() {
system("cls");
system("color BF");
cout<<setw(75)<<"A.第一关"<<setw(6)<<" B.第二关\n"<<setw(75)<<"C.第三关"<<setw(6)<<" D.第四关\n"<<setw(75)<<"E.第五关"<<setw(6)<<" F.第六关\n"<<setw(75)<<"G.第七关"<<setw(6)<<" H.第八关\n"<<setw(75)<<"I.第九关"<<setw(6)<<" J.第十关\n";
do {
choose=getch();
} while(choose>gxia||choose<'A');
}
void ddd() {
MessageBox(GetForegroundWindow(),"游戏中会随机生成一个数,你要找出这个\n数(猜的次数只有10次)(第五关重来几次\n有几率次数减少)","帮助",1);
}
void num1() {
system("cls");
system("color 4E");
rand1=rand()%31+20;
do {
cin>>numn;
cishu++;
if(numn<rand1) cout<<"太小了!!!\n";
if(numn>rand1) cout<<"太大了!!!\n";
if(cishu>=10) flag=false;
} while(numn!=rand1&&cishu<10);
if(flag) {
cout<<"恭喜你猜中了!"<<endl<<"这个数是"<<rand1<<"!\n"<<endl;
cout<<"你猜了"<<cishu<<"次"<<endl;
gxia++;
}
if(flag==false) cout<<