C++足球比分预测器(包过的)

//作者:Oliver_Kahn(洛谷同名) 
#include<bits/stdc++.h>
using namespace std;
int jdjs(){
	srand(time(0));//随机数种子
	cout<<"欢迎使用足球比分预测器!"<<endl<<"请输入主队名称:"<<endl;//给使用者提供提示
	string m,ml;//定义字符串,方便我们存储两队队名
	cin>>m;//输入字符串m
	cout<<"请输入客队名称:";
	cin>>ml; 
		int a,b,s;
	a=rand()%10000; //如果a==1,我们就当作发生了惨案(x洗)
	cout<<"请输入模式"<<endl<<"输入为1则为联赛模式,输入为2则为欧冠模式(两回合),输入3即为欧冠决赛模式(附带点球)"<<endl; //提供提示
	int mood;
	cin>>mood;//模式
	if(mood==1)//模式为1
	{
	if(a==1){
		b=rand()%7+rand()%5;//惨案的比分
		s=rand()%2+rand()%1;
		cout<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
	} 
	else cout<<m<<" "<<rand()%6<<":"<<rand()%6<<" "<<ml<<endl;
}
else if(mood!=1&&mood!=2&&mood!=3)//防止干爆程序
{
cout<<"请不要戏耍机器,机器已关闭,欢迎您下次使用"<<endl;
return 3;//整个活,反正没用
}
else if(mood==2)//模式为2
{	
int za=0,zb=0; //总比分
if(a==1){
		b=rand()%7+rand()%5;
		s=rand()%2+rand()%1;
		cout<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
		za+=b;
		zb+=s;
	} 
	else {
		b=rand()%6;
		s=rand()%6;
		cout<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
		za+=b;//总比分加上常规时间双方的比分
		zb+=s;
	}
	int ks;//次回合
	ks=rand()%10000;
	if(ks==1)
	{		b=rand()%7+rand()%5;
		s=rand()%2+rand()%1;
		cout<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
		za+=b;
		zb+=s;
	}
	else {
			b=rand()%4;
		s=rand()%4;
		cout<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
		za+=b;
		zb+=s;//非惨案情况
	}
	cout<<"总比分"<<za<<":"<<zb<<endl;
	if(za==zb)
	{
	cout<<"加时赛开始"<<endl;
	int kk=0,kkk=0;
	int sk,sl;
	sk=rand()%15;
	sl=rand()%15;
	if(sk==1) 
	kk=rand()%3;
	if(sl==1)
	kkk=rand()%3;//加时赛,双方有1/3的概率可以进球
	za+=kk;
	zb+=kkk;
	cout<<"加时赛比分"<<kk<<":"<<kkk<<endl<<"总比分"<<za<<":"<<zb<<endl; 
	if(za==zb)
	{
		cout<<"点球大战开始:"<<endl;
		int d1,d2,df=0,db=0,klk=1;
		for(int i=1;i<=5;i++)
		{
			cout<<"第"<<klk<<"轮:"; 
			d1=rand()%18;
			if(d1!=1)
			{
				df++;
				za++; 
			}
				d2=rand()%18;
			if(d2!=1)
			{
				db++;
				zb++;
			}
			cout<<df<<" "<<db<<endl;
			klk++;
		}
		if(zb==za)
		{
			while(zb==za)
			{
				cout<<"第"<<klk<<"轮:";
				d1=rand()%13;
				klk++;
				if(d1!=1)
			{
				df++;
				za++; 
			}
		if(d1!=1)
		{
			d2=rand()%12;
		} 
		else d2=rand()%14;//心理压力(雾)
					if(d2!=1)
			{
				db++;
				zb++;
			}
			cout<<df<<" "<<db<<endl;
			}
		}
		cout<<"点球大战结束,比分:"<<df<<":"<<db<<endl<<"总比分"<<za<<":"<<zb<<endl; 
	}
}
if(za>zb)
{
	cout<<m<<"晋级!"<<endl; 
}
else cout<<ml<<"晋级!"<<endl; 
}
if(mood==3)
{
	int a=rand()%1000;
	if(a==1){
		b=rand()%7+rand()%5;
		s=rand()%2+rand()%1;
		cout<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
	} 
	else {
		b=rand()%5;
		s=rand()%5;
		cout<<"总比分:"<<m<<" "<<b<<":"<<s<<" "<<ml<<endl;
	}
	if(b==s) 
	{
		int d1,d2,df=0,db=0,klk=1;
		for(int i=1;i<=5;i++)
		{
			cout<<"第"<<klk<<"轮:"; 
			d1=rand()%18;
			if(d1!=1)
			{
				df++;
				b++; 
			}
				d2=rand()%18;
			if(d2!=1)
			{
				db++;
				s++;
			}
			cout<<df<<" "<<db<<endl;
			klk++;
		}
		if(b==s)
		{
			while(b==s)
			{
				cout<<"第"<<klk<<"轮:";
				d1=rand()%13;
				klk++;
				if(d1!=1)
			{
				df++;
				b++; 
			}
		if(d1!=1)
		{
			d2=rand()%12;
		} 
		else d2=rand()%14;
					if(d2!=1)
			{
				db++;
				s++;
			}
			cout<<df<<" "<<db<<endl;
			}
		}
		cout<<"点球大战结束,比分:"<<df<<":"<<db<<endl<<"总比分"<<b<<":"<<s<<endl; 
	}
	if(b>s)
	cout<<"恭喜"<<m<<"夺得冠军!"<<endl;
	else
	cout<<"恭喜"<<ml<<"夺得冠军!"<<endl;
	return 0;
}
}
int main(){
	int k=10;
	char ccc;
	while(k>1)
	{
		jdjs();//不断调用函数
		cout<<"请问您还要继续预测吗?(Y为继续,输入其他则为结束)"<<endl; 
		cin>>ccc;
		if(ccc=='Y')
		continue;
		else k=1;//出口
	}
system("pause");
return 0;
}
	

百分百可运行,若遇到此情况报错,去看看你exe关没(

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值