Oyjq2011 @ 2024-08-06 20:46:01
#include <iostream>
using namespace std;
int main() {
// 输入部分
string s = "";
char c;
while(true) {
cin >> c;
if(c != 'E') {
s += c;
}
else {
break;
}
}
// 十一分制
int w = 0,l = 0;
for(int i = 0;i < s.size();i++) {
if(s[i] == 'W') {
w++;
if(w >= 11 && (w-l) >= 2) {
cout << w << ':' << l << endl;
w = 0;
l = 0;
}
}
else {
l++;
if(l >= 11 && (l-w) >= 2) {
cout << w << ':' << l << endl;
w = 0;
l = 0;
}
}
}
if(w != 0 || l != 0) {
cout << w << ':' << l << endl << endl;
}
else if(s.size() == 0) {
cout << "0:0" << endl << endl;
}
// 二十一分制
w = 0;
l = 0;
for(int i = 0;i < s.size();i++) {
if(s[i] == 'W') {
w++;
if(w >= 21 && (w-l) >= 2) {
cout << w << ':' << l << endl;
w = 0;
l = 0;
}
}
else {
l++;
if(l >= 21 && (l-w) >= 2) {
cout << w << ':' << l << endl;
w = 0;
l = 0;
}
}
}
if(w != 0 || l != 0) {
cout << w << ':' << l;
}
else if(s.size() == 0) {
cout << "0:0";
}
return 0;
}
by Lby_jason @ 2024-08-06 21:02:32
试试这个样例,别人哪里找的 WWWWWWWWWWWE 错误答案: 11:0
11:0 正确答案: 11:0 0:0
11:0
by sherry666 @ 2024-08-06 21:04:39
@Lby_jason 下载的样例吧
by Lby_jason @ 2024-08-07 07:43:52
@sherry666 是的,从别人哪里找的,希望能有些帮助
by Lby_jason @ 2024-08-07 07:46:19
@sherry666 我也错这个点,改了就对了