90分第五个wa求探讨

P1320 压缩技术(续集版)

yegetables @ 2020-12-01 14:26:59

第五个数据 结果显示一样 linux下用od out -c查看样例输出和自己的输出 发现少一个空格和\r\n 手动添上后仍然过不了

#include <stdio.h>
int main()
{
    char c;
    int line = 0;
    int i = 0;
    int a[100000] = {0};
    //   int b[1000] = {0};
    scanf("%c", &c);
    int z = 0, sumx = 0;
    while (c == '0' || c == '1')
    {
        while (c == '0' || c == '1')
        {

            a[i] = c - '0';
            i++;
            z++;

            scanf("%c", &c);
            if (c == '\r')
                scanf("%c", &c);
        }

        line++;

        if (z > sumx)
            sumx = z;
        z = 0;
        if (line == sumx)
        {
            a[line * line] = a[line * line - 1] + 1;
            break;
        }
        else
            scanf("%c", &c);
        if (c == '\r')
            scanf("%c", &c);
    }
    printf("%d", line);
    //i = 个数
    int sum = 0;
    int x = 1;
    int th = 0;
    while (sum < i)
    {
        if (a[0] != 0 && th == 0)
        {
            printf(" 0");
            th = 1;
            sum--;

            x--;
        }
        else if (a[sum] != a[sum + 1])
        {
            printf(" %d", x);
            x = 0;
        }
        x++;
        sum++;
        //printf("xxx\n");
    }
    printf(" \r\n");
    // printf("%d", sum);
}
//printf("1");
//printf("%c", c);

by sss6666 @ 2020-12-25 07:29:08

第五个wa是什么呀


by buaaxxr @ 2021-01-31 21:14:33

我也是第五个wa了。。


by buaaxxr @ 2021-01-31 21:29:11

应该是丢了个换行,最后手动输出错误数据过了


|