c++游戏 NO 5 速算游戏

先上源代码(最后一张有神秘物品):

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攒出注释。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值