第十个测试点为什么要补0:0

P1042 [NOIP2003 普及组] 乒乓球

abc583 @ 2024-05-21 22:04:46

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    char c;
    int w = 0, l = 0, tw = 0, tl = 0;
    int re1[3000] = { 0 }, re2[3000] = { 0 }, r = 0, rr = 0;
    while (cin >> c, c != 'E')
    {
        if (c == 'W') { w++; tw++; }
        else { l++; tl++; }
        if (abs(w - l) >= 2) {
            if (w >= 11 || l >= 11)
            {
                cout << w << ":" << l << endl;
                w = 0; l = 0;
                r++;
            }
        }
        if (abs(tw - tl) >= 2) {
            if (tw >= 21 || tl >= 21)
            {
                re1[rr] = tw; re2[rr] = tl;
                tw = 0; tl = 0;
                rr++;
            }
        }
    }
    if (w || l)
        cout << w << ":" << l << endl;
    else if (r == 0) //如果删掉if(r==0)就ac了
        cout << "0:0" << endl;
    cout << endl;
    for (int i = 0; i < rr; i++)
        cout << re1[i] << ":" << re2[i] << endl;
    if (tw || tl)
        cout << tw << ":" << tl << endl;
    else if (r == 0)
        cout << "0:0" << endl;
}

为什么刚好11:0之后还要输出一个0:0呢?求大佬解答


by liuhaoyan0323 @ 2024-05-21 22:44:46

没什么太大影响吧


by Alex866 @ 2024-06-30 09:08:21

因为一局刚开始


|