求助!!2345wa!!
查看原帖
求助!!2345wa!!
636358
WindyDay楼主2022/7/25 19:44
#include<iostream>
#include<cmath>
using namespace std;

struct score
{
	int a, b;
	void print()
	{
		cout << a << ":" << b << endl;
	}
} now = {0, 0};

int main()
{
	char n;
	string t = "";
	while(1)
	{
		cin >> n;
		t += n;
		switch(n)
		{
			case 'W':
				now.a++;
				break;
			case 'L':
				now.b++;
				break;
			case 'E':
				now.print();
				goto k;
		}
		if(now.a == 11 || now.b == 11)
		{
			if(abs(now.a - now.b) >= 2)
			{
				now.print();
				now = {0, 0};
			}
		}
	}
	k: now = {0, 0};
	cout << endl;
	for(int i = 0; i < t.size(); i++)
	{
		switch(t[i])
		{
			case 'W':
				now.a++;
				break;
			case 'L':
				now.b++;
				break;
			case 'E':
				now.print();
				return 0;
		}
		if(now.a == 21 || now.b == 21)
		{
			if(abs(now.a - now.b) >= 2)
			{
				now.print();
				now = {0, 0};
			}
		}
	} 
	return 0;
}

2022/7/25 19:44
加载中...