样例过了全WA

P1320 压缩技术(续集版)

lingtingting123 @ 2023-11-15 20:27:02

求助,代码样例过了,全WA,救救孩子

#include<stdio.h>
int main() {
    char c;
    int a[40020] = { 0 };
    int i = 1, flag;
    for (; scanf("%c", &c) && c > 47 && c < 50;)
        i += !(i & 1 ^ (c - '0')), a[i]++, a[0]++;
    for (int j = 1; j < a[0]; j++) {
        for (; scanf("%c", &c) && c > 47 && c < 50;)
            i += !(i & 1 ^ (c - '0')), a[i]++;
    }
    flag = i;
    for (int i = 0; i <= flag; i++) {
        printf("%d ", a[i]);
    }
    return 0;
}

|