题目链接:https://www.luogu.org/problemnew/show/P1042
这道题目刚开始自己是卡在了数据的输入和如何把二维的字符矩阵转化为一维的字符串。
#include <iostream>
#include <string.h>
using namespace std;
const int MAX_N = 25 * 2500 + 100;
char str_one[25 + 5], str[MAX_N];
int main () {
int i, w;
while (cin >> str_one) {
int len = strlen (str_one);
for (i = 0; i < len; i++) {
if (str_one[i] == 'E') {
int sum_one = 0, sum_two = 0, j = 0;
for (j; j < w; j++) {
if (str[j] == 'W') sum_one ++;
if (str[j] == 'L') sum_two ++;
if ((sum_one >= 11 && sum_one - sum_two >= 2) || (sum_two >= 11 &&sum_two - sum_one >= 2)) {
cout << sum_one << ":" << sum_two << endl;
sum_one = 0; sum_two = 0;
}
}
cout << sum_one << ":" << sum_two << endl << endl;
sum_one = 0; sum_two = 0;
for (j = 0; j < w; j++) {
if (str[j] == 'W') sum_one ++;
if (str[j] == 'L') sum_two ++;
if ((sum_one >= 21 && sum_one - sum_two >= 2) || (sum_two >= 21 &&sum_two - sum_one >= 2)) {
cout << sum_one << ":" << sum_two << endl;
sum_one = 0; sum_two = 0;
}
}
cout << sum_one << ":" << sum_two << endl;
return 0;
}
else str[w++] = str_one[i];
}
}
return 0;
}