60分求调,给几个测试点也行

P1042 [NOIP2003 普及组] 乒乓球

Bamboopencil @ 2024-10-29 10:38:52

#include <stdio.h>
#include <stdlib.h>
int main() 
{
    char arr[1000000];
    char ch;
    int i = 0;
    while((ch = (char)getchar()) != 'E'&& i < 1000000)
    {
        arr[i] = ch;
        i++;
    }

    struct score
    {
        int a;
        int b;
    };
    //a为华华,b为华华对手
    struct score score_11 = {0, 0};
    struct score score_21 = {0, 0};

    i = 0;
    //计算11点
    while(arr[i] != '\0' && arr[i] != 'E')
    {

        if(arr[i] == 'W')
        {
            score_11.a++;
        }
        if(arr[i] == 'L')
        {
            score_11.b++;
        }
        i++;
        if((score_11.a>=11 || score_11.b>=11) && abs(score_11.a - score_11.b) > 2 )
        {
            printf("%d:%d\n", score_11.a, score_11.b);
            score_11.a = 0;
            score_11.b = 0;
        }

    }
    printf("%d:%d\n", score_11.a, score_11.b);
    printf("\n");
    i = 0;
    //计算21点
    while(arr[i] != '\0' && arr[i] != 'E')
    {

        if(arr[i] == 'W')
        {
            score_21.a++;
        }
        if(arr[i] == 'L')
        {
            score_21.b++;
        }
        i++;
        if((score_21.a>=21 || score_21.b>=21) && abs(score_21.a - score_21.b) > 2)
        {
            printf("%d:%d\n", score_21.a, score_21.b);
            score_21.a = 0;
            score_21.b = 0;
        }

    }
    printf("%d:%d\n", score_21.a, score_21.b);
    return 0;
}

第二三四五个测试点死活过不去


by czwa1234 @ 2024-10-29 13:46:23

差值大于等于2,改一下,还有你这样写太麻烦了


by flashfear @ 2024-11-08 19:14:43

最后一个测试点是WWWWWWWWWWWEadfadf;jadf

11:0
0:0

11:0

反正我都下了,你也要了,那我就发出来吧(doge)指不定能帮到其他进帖子的人呢。


|