不求AC代码,求改,代码应该不算复杂 a表示第一个人的分数,b是第二个人的,函数判断是否超过两分(不会绝对值函数,
# include<bits/stdc++.h>
using namespace std;
int a, b, x;
bool a_b(int x, int y){
if(x > y){
if(x - y >= 2) return true;
else return false;
}
if(x < y){
if(y - x >= 2) return true;
else return false;
}
if(x == y) return false;
}
void C(){
cout << a << ":" << b << endl;
}
int main(){
string s1, s;
while(1){
cin >> s1;
s += s1;
if(s[s.length() - 1] == 'E') break;
}
for(int i = 0; i < s.length() - 1; i++){
if(s[i] == 'W') a++;
if(s[i] == 'L') b++;
if(a + b >= 11){
if(a_b(a, b)){
C();
a = 0, b = 0;
}else{
x = 1;
}
if(x == 1){
if(a_b(a, b)){
C();
x = 0, a = 0, b = 0;
}
}
}
}
C();
cout << endl;
a = 0, b = 0, x = 0;
for(int i = 0; i < s.length() - 1; i++){
if(s[i] == 'W') a++;
if(s[i] == 'L') b++;
if(a + b >= 21){
if(a_b(a, b)){
C();
a = 0, b = 0;
}else{
x = 1;
}
if(x == 1){
if(a_b(a, b)){
C();
x = 0, a = 0, b = 0;
}
}
}
}
C();
return 0;
}