字符串拼接
查看原帖
字符串拼接
639311
huhaohuu楼主2022/11/14 16:25
#include<bits/stdc++.h>
using namespace std;

int main() {
    string a,b="";
    long long numW=0,numL=0;

    while(1) {
        cin>>a;
        int pos=a.find('E');
        if(pos !=a.npos) { //npos表示没找到
            for(int i=0;i<pos;i++) {
                b+=a[i]; //拼接
            }
            break;
        }
        b=b+a;
    }
    
    for(long long i=0;i<b.size();i++) {
        if(b[i] == 'W') numW++;
        if(b[i] == 'L') numL++;
        if((numW >= 11 or numL>=11) and abs(numW-numL)>=2) {
            cout<<numW<<":"<<numL<<endl;
            numW=0;
            numL=0;
        }
    }
    cout<<numW<<":"<<numL<<endl; //输出没比完的分值
    cout<<endl;

    numW=0;
    numL=0;
    for(long long i=0;i<b.size();i++) {
        if(b[i] == 'W') numW++;
        if(b[i] == 'L') numL++;
        if((numW >= 21 or numL>=21) and abs(numW-numL)>=2) {
            cout<<numW<<":"<<numL<<endl;
            numW=0;
            numL=0;
        }
    }
    cout<<numW<<":"<<numL<<endl; //输出没比完的分值

	return 0;
}
2022/11/14 16:25
加载中...