求助大佬,他WA显示是某一行too short是为啥
查看原帖
求助大佬,他WA显示是某一行too short是为啥
606365
Ausert楼主2022/10/25 19:21

debug出来发现是11分制的结果和21分制的结果中间的要空行的那边他告诉我太短了,有谁知道知道这是为什么的吗o(╥﹏╥)o? 以下为源代码

#include<bits/stdc++.h>
using namespace std;
#define INF 2100000000;



void solve()
{
	char a;
	cin >> a;
	string str;
	if(a!='E')str += a;
	while (a != 'E') {
		cin >> a;
		if(a!='E') str += a;
	}
	int n = str.size();
	int winCnt_11=0, lostCnt_11=0, winCnt_21=0, lostCnt_21 = 0;
	for (int i = 0; i < n; i++) {
		if (str[i] == 'W') {
			winCnt_11++;
		}
		if (str[i] == 'L') {
			lostCnt_11++;
		}
		if (abs(winCnt_11 - lostCnt_11) >= 2) {
			if (winCnt_11 >= 11) {
				cout << winCnt_11 << ':' << lostCnt_11<< endl;
				winCnt_11 = 0;
				lostCnt_11 = 0;
			}
			else if (lostCnt_11 >= 11) {
				cout << winCnt_11 << ':' << lostCnt_11 << endl;
				winCnt_11 = 0;
				lostCnt_11 = 0;
			}
		}
		if (i == n - 1&&winCnt_11!=0&&lostCnt_11!=0) {
			cout << winCnt_11 << ':' << lostCnt_11 << endl;
		}
	}
	if (n == 0) {
		cout << 0 << ':' << 0 << endl;
		cout << endl;
		cout << 0 << ':' << 0<< endl;
	}
	else {
		cout << endl;
	}
	for (int i = 0; i < n; i++) {
		if (str[i] == 'W') {
			winCnt_21++;
		}
		if (str[i] == 'L') {
			lostCnt_21++;
		}
		if (abs(winCnt_21 - lostCnt_21) >= 2) {
			if (winCnt_21 >= 21) {
				cout << winCnt_21 << ':' << lostCnt_21 << endl;
				winCnt_21 = 0;
				lostCnt_21 = 0;
			}
			else if (lostCnt_21 >= 21) {
				cout << winCnt_21 << ':' << lostCnt_21<< endl;
				winCnt_21 = 0;
				lostCnt_21 = 0;
			}
		}
		if (i == n - 1 && winCnt_21 != 0 && lostCnt_21 != 0) {
			cout << winCnt_21 << ':' << lostCnt_21<< endl;
		}
	}
}


int main()
{

		solve();
	
	return 0;
}
2022/10/25 19:21
加载中...