关于我本地完全对提交全WA这件事请大佬解决一下

P1320 压缩技术(续集版)

Clouderr @ 2022-07-16 22:27:05


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,temp;
    char map[201][201],c,last;
    scanf("%c",&c);
    for (n=0;c!='\n';n++)
    {
        map[0][n]=c;
        scanf("%c",&c);
    }
    for (i=1;i<n;i++)
    {
        for (j=0;j<n;j++)
        {
            scanf("%c",&map[i][j]);
        }
        scanf("%c",&c);
    }
    int out[n*n+1];
    temp=0;
    last='0';
    k=0;
    for (i=0;i<n;i++)
    {
        for (j=0;j<n;j++)
        {
            if (map[i][j]==last) temp++;
            else
            {
                out[k]=temp;
                k++;
                temp=1;
            }
            last=map[i][j];
        }
    }
    out[k]=temp;
    k++;
    printf("%d ",n);
    for (i=0;i<k;i++)
    {
        printf("%d ",out[i]);
    }
    return 0;
}

by Clouderr @ 2022-07-16 22:35:34

for (n=0;c!='\n';n++)//这里是n
    {
        num[0][n]=c;
        scanf("%c",&c);
    }

by bamboo12345 @ 2022-07-16 22:38:49

@Clouderr 你再交一发?


by Clouderr @ 2022-07-16 22:40:28

@bamboo123 全WA


by bamboo12345 @ 2022-07-16 22:42:50

@Clouderr 你把n减掉一个1


by Clouderr @ 2022-07-16 22:44:59

@bamboo123 话说我测试过这个程序了,n没问题


by bamboo12345 @ 2022-07-16 22:46:33

@Clouderr 有问题,你要看记录详情里你的n好像就是多了1(输出答案减掉应该就可以了)


by Clouderr @ 2022-07-16 22:49:32

@bamboo123 WA


by Clouderr @ 2022-07-16 22:50:07

我先睡了,明天再想


by bamboo12345 @ 2022-07-17 08:40:08

@Clouderr 你计算out的方式有问题


by bamboo12345 @ 2022-07-17 09:06:33

@Clouderr 输入完第一行后立刻把n减掉一,输出时不用减就能AC了


上一页 | 下一页