代码

#include <bits/stdc++.h>
using namespace std;
const char WIN='W';
const char LOST='L';
const char END='E';
const char COLON=':';
int main(){
    char now;
    stringstream s11,s21; \\使用字符串流
    int a_11=0,b_11=0,a_21=0,b_21=0;\\其中a代表我方,b代表对方。
    while(cin>>now){\\当没有输入时,cin>>now为false
        if(now==WIN){
            a_11++;
            a_21++;
        }
        if(now==LOST){
            b_11++;
            b_21++;
        }
        if(now==END){
            break;
        }
        if((a_11>=11||b_11>=11)&&abs(a_11-b_11)>=2){
            s11<<a_11<<COLON<<b_11<<endl;
            a_11=0;
            b_11=0;
        }
        if((a_21>=21||b_21>=21)&&abs(a_21-b_21)>=2){
            s21<<a_21<<COLON<<b_21<<endl;
            a_21=0;
            b_21=0;
        }
    }
    s11<<a_11<<COLON<<b_11<<endl;
    a_11=0;
    b_11=0;
    s21<<a_21<<COLON<<b_21<<endl;
    a_21=0;
    b_21=0;
    cout<<s11.str()<<endl<<s21.str();
    return 0;
}
Last modification:July 8, 2019
如果您觉得我的文章有用,给颗糖糖吧~