先上源代码(最后一张有神秘物品):
bool jisuan()
{
int min=1,max=9;
bool flag=true;
int a,b,c,d;
unsigned long long seed;
max=99;
seed=(unsigned)time(NULL);
a=suiji(min,max,seed);
b=(suiji(min,max,seed+17)*suiji(min,max,seed+7)*suiji(min,max,seed-1))%100;
c=suiji(0,1,seed);
cout<<a;
if(c==0)
{
cout<<"+";
cout<<b<<"=";
cin>>d;
if(d==(a+b))
{
cout<<"Correct!"<<endl;
}
else
{
flag=false;
}
}
else
{
cout<<"-";
cout<<b<<"=";
cin>>d;
if(d==(a-b))
{
cout<<"Correct!"<<endl;
}
else
{
flag=false;
}
}
return flag;
}
int susuan()
{
int min=1,max=9,s=0;
int a,b,c,d;
unsigned long long seed;
start:cout<<"欢迎来到速算王者!"<<endl;
cout<<"请选择:"<<endl;
cout<<"1.简单模式"<<endl;
cout<<"2.中等模式"<<endl;
cout<<"3.困难模式"<<endl;
cout<<"4.终极模式(新)"<<endl;
cout<<"5.关于本游戏"<<endl;
int n,i=0;
cin>>n;
if(n!=1&&n!=2&&n!=3&&n!=4&&n!=5)
{
cout<<"你输错了!"<<endl;
goto start;
}
if(n==1)
{
cout<<"准备开始!每题限时"<<longlong<<"秒"<<endl;
total=shorttime;
Sleep(1.5*1000);
for(;;)
{
start=getCurrentTime();
total=longlong-(getCurrentTime()-start)/1000.0;
if(jisuan()==true)
{
//cout<<"本题用时"<<(getCurrentTime()-start)/1000.0<<"秒"<<endl;
if((getCurrentTime()-start)/1000.0>longlong)
{
cout<<"答题超时......"<<endl;
cout<<"得分:"<<s<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
else
{
s++;
}
}
else
{
cout<<"错误......"<<endl;
cout<<"得分:"<<s<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
}
}
else if(n==2)
{
cout<<"准备开始!限时"<<longtime<<"秒"<<endl;
total=shorttime;
Sleep(1.5*1000);
for(;;)
{
start=getCurrentTime();
total=longlong-(getCurrentTime()-start)/1000.0;
if(jisuan()==true)
{
//cout<<"本题用时"<<(getCurrentTime()-start)/1000.0<<"秒"<<endl;
if((getCurrentTime()-start)/1000.0>longtime)
{
cout<<"答题超时......"<<endl;
cout<<"得分:"<<s<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
else
{
s++;
}
}
else
{
cout<<"错误......"<<endl;
cout<<"得分:"<<s<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
}
}
else if(n==3)
{
cout<<"准备开始!限时"<<shorttime<<"秒"<<endl;
total=shorttime;
Sleep(1.5*1000);
for(;;)
{
start=getCurrentTime();
total=longlong-(getCurrentTime()-start)/1000.0;
if(jisuan()==true)
{
//cout<<"本题用时"<<(getCurrentTime()-start)/1000.0<<"秒"<<endl;
if((getCurrentTime()-start)/1000.0>shorttime)
{
cout<<"答题超时......"<<endl;
cout<<"得分:"<<s<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
else
{
s++;
}
}
else
{
cout<<"错误......"<<endl;
cout<<"得分:"<<s<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
}
}
else if(n==4)
{
cout<<"准备开始!时间会越来越少!"<<endl;
total=shorttime;
Sleep(1.5*1000);
for(;;)
{
start=getCurrentTime();
total=longlong-(getCurrentTime()-start)/1000.0;
if(jisuan()==true)
{
//cout<<"本题用时"<<(getCurrentTime()-start)/1000.0<<"秒"<<endl;
if(s==35)
{
cout<<"恭喜恭喜,你胜利了!!!"<<"\n"<<"称号:举世无双的大师"<<endl;
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
if((getCurrentTime()-start)/1000.0>longtime-s/10)
{
cout<<"答题超时......"<<endl;
cout<<"得分:"<<s<<endl;
if(s<8)
{
cout<<"称号:初级玩家"<<endl;
}
if(s>=8&&s<15)
{
cout<<"称号:中级玩家"<<endl;
}
if(s>=16&&s<25)
{
cout<<"称号:高级玩家"<<endl;
}
if(s>=25&&s<35)
{
cout<<"称号:超一流玩家"<<endl;
}
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
else
{
s++;
}
}
else
{
cout<<"错误......"<<endl;
cout<<"得分:"<<s<<endl;
if(s<8)
{
cout<<"称号:初级玩家"<<endl;
}
if(s>=8&&s<15)
{
cout<<"称号:中级玩家"<<endl;
}
if(s>=16&&s<25)
{
cout<<"称号:高级玩家"<<endl;
}
if(s>=25&&s<35)
{
cout<<"称号:超一流玩家"<<endl;
}
cout<<"输q退出,其他字符重来";
char ch;
cin>>ch;
if(ch=='q')
{
return 0;
}
else
{
system("cls");
s=0;
goto start;
}
}
}
}
else
{
cout<<"本游戏由bear工作坊出品"<<"\n";
cout<<"游戏版本号:v10.39.12w" <<"\n";
s=0;
goto start;
}
}
老规矩,24攒出注释。