帮忙看看哪里有问题
查看原帖
帮忙看看哪里有问题
1366676
dhhhhh1235楼主2024/12/4 21:02
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int f[2] = { 11,21 };
	int n=0;
	int a[2500 * 25 + 10];
	char temp;
	while (1) {
		cin >> temp;
		if (temp == 'E') break;
		else if (temp == 'W') a[n++] = 1;
		else if (temp == 'L') a[n++] = 0;
	}
	for (int i = 0;i < 2;i++)
	{
		int l = 0, w = 0;
		for (int j = 0;j<n;j++)
		{
			w += a[j], l += 1 - a[j];
			if (max(w, l) >= f[i] && abs(w - l) >= 2)
			{
				cout << w << ": " << l<<endl;
				w =l = 0;
			}
		}
		cout << w << ": " << l << endl;
		cout << endl;
	}
	return 0;
}
2024/12/4 21:02
加载中...