40分 2MLE 4WA 4AC 五颜六色求助
查看原帖
40分 2MLE 4WA 4AC 五颜六色求助
553640
Konjac0629楼主2023/8/27 10:01

RT,大佬们帮忙看看哪里出问题了

记录:122934907

#include <bits/stdc++.h>

using namespace std;

vector<string> scoreInfo;

int main(){
    // 读入比分信息并删除掉末尾的E

    while(1){
        string temp;
        cin >> temp;
        scoreInfo.push_back(temp);
        if(scoreInfo.back().back()=='E'){
            scoreInfo.back().erase(scoreInfo.back().length()-1);
            break;
        }
    }

    // 将vector转成string

    string strScoreInfo="";

    for(int i=0;i<scoreInfo.size();i++)
        strScoreInfo+=scoreInfo[i];

    // 开始11分制的比分计算

    int scoreA_11=0,scoreB_11=0,nowJu=1;
    for(int j=0;j<strScoreInfo.length();j++){
        if(strScoreInfo[j]=='W'){
            // 华华得分
            scoreA_11++;
        }
        else{
            // 华华对手得分
            scoreB_11++;
        }
        if(nowJu==11||j==strScoreInfo.length()-1){
            if(abs(scoreA_11-scoreB_11)>=2||j==strScoreInfo.length()-1){
                nowJu=0;
                cout << scoreA_11 << ":" << scoreB_11 << endl;
                scoreA_11=0;
                scoreB_11=0;
            }
            else{
                continue;
            }
        }
        nowJu++;
    }
    
    // 输出回车

    cout << endl;

    // 开始21分制的比分计算

    int scoreA_21=0,scoreB_21=0;
    nowJu=1;
    for(int k=0;k<strScoreInfo.length();k++){
        if(strScoreInfo[k]=='W'){
            // 华华得分
            scoreA_21++;
        }
        else{
            // 华华对手得分
            scoreB_21++;
        }
        if(nowJu==21||k==strScoreInfo.length()-1){
            if(abs(scoreA_21-scoreB_21)>=2||k==strScoreInfo.length()-1){
                nowJu=0;
                cout << scoreA_21 << ":" << scoreB_21 << endl;
                scoreA_21=0;
                scoreB_21=0;
            }
            else{
                continue;
            }
        }
        nowJu++;
    }
    return 0;
}
2023/8/27 10:01
加载中...