20pts, 求调!

P1042 [NOIP2003 普及组] 乒乓球

zhexj @ 2024-07-07 19:19:33

code:
#include <bits/stdc++.h>
using namespace std;
int len, xh, xg;
char c;
string s;

void eleven()
{
    int W = 0, L = 0;
    for(int i = 0; i < len; i++)
    {
        if(s[i] == 'W')
            W++;
        else
            L++;
        if((W >= 11 && W - L >= 2) || (L >= 11 && L - W >= 2))
        {
            printf("%d:%d\n", W, L);
            W = L = 0;
        }
    }
    printf("%d:%d\n\n", W, L);
}

void twenty_one()
{
    int W = 0, L = 0;
    for(int i = 0; i < len; i++)
    {
        if(s[i] == 'W')
            W++;
        else
            L++;
        if((W >= 21 && W > L && W - L >= 2) || (L >= 21 && L > W && L - W >= 2))
        {
            printf("%d:%d\n", W, L);
            W = L = 0;
        }
    }
    printf("%d:%d", W, L);
}

int main()
{
    while(1)
    {
        scanf("%c", &c);
        if(c == 'E')
            break;
        if(c == '\n')
            continue;
        s += c;
    }
    len = s.length();
    printf("%d\n", len);
    eleven();
    twenty_one();
    return 0;
}

第一个和最后一个A了


by Ivan422 @ 2024-07-07 19:52:58

调试没删

给个关注谢谢喵


by zhexj @ 2024-07-07 20:27:46

@Ivan422 删了还是20


by zhexj @ 2024-07-07 20:48:38

@Ivan422 但还是谢谢orz,关注啦


|