为什么我的数组没有被赋值???

P1320 压缩技术(续集版)

LabmemNo_012LzTopic @ 2023-12-18 19:31:03

#include<stdio.h>
char a[205][205];
int b[205];
int main(void)
{
    char c,h='0';
    int s = 0,i,j=1,k=1,g=1;
    while ((c = getchar()) != '\n')
    {
        a[1][j++] = c;
        s++;
        if (a[1][j] == h)b[k]++;
        else
        {
            h = '1';
            k++;
            g++;
        }
    }
    for (i = 2; i <= s; i++)
    {
        for (j = 1; j <= s; j++)
        {
            a[i][j] = getchar();
        }
        if (a[1][j] == h)b[k]++;
        else
        {
            h = '1';
            k++;
            g++;
        }
    }
    printf("%d ", s);
    for (i = 1; i <= g; i++)
    {
        printf("%d ", b[i]);
    }
    return 0;
}

|