【模拟】【洛谷】【P1042乒乓球】

/*
	【模拟】【洛谷】【P1042乒乓球】 
*/ 

#include<iostream>
#include<cmath>
using namespace std;
const int maxn=1e6+10;
typedef struct node{
	int win=0;
	int lose=0;
};
node a[maxn],b[maxn];//11分制   21分制
int main()
{
	string str;
	int cotA=0,cotB=0;
	bool f=true;
	while(f)
	{
		cin>>str;
		for(int i=0;i<str.size();i++)
		{
			if(str[i]=='E')
			{
				f=false;
				break;
			}
			if(str[i]=='W') {
				a[cotA].win++;
				b[cotB].win++;	
			}
			else{
				a[cotA].lose++;
				b[cotB].lose++;
			} 
			if(a[cotA].win==11&&a[cotA].lose<=9||a[cotA].win<=9&&a[cotA].lose==11)
				cotA++;
			else if((a[cotA].win>11||a[cotA].lose>11)&&abs(a[cotA].win-a[cotA].lose)==2)
				cotA++;
				
			if(b[cotB].win==21&&b[cotB].lose<=19||b[cotB].win<=19&&b[cotB].lose==21)
				cotB++;
			else if((b[cotB].win>21||b[cotB].lose>21)&&abs(b[cotB].win-b[cotB].lose)==2)
				cotB++;				
		}
	}
	/*
		想到了 如果最后比分是8:7的情况 下面要++
		但没想到 上面如果是11:8的情况  已经结束一局以后  还要输出0:0
		真就离大谱  这考试的话 怎么办呢? 
	*/
	cotA++;   cotB++;
	for(int i=0;i<cotA;i++)
	{
		cout<<a[i].win<<":"<<a[i].lose<<"\n";
	}
	cout<<"\n";
	for(int i=0;i<cotB;i++)
	{
		cout<<b[i].win<<":"<<b[i].lose<<"\n"; 
	}
	return  0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值