洛谷ide机结果正确,但提交全是wa

P5730 【深基5.例10】显示屏

qwq_it_is_me @ 2021-04-02 21:50:18

如题 求助

说第一个字符是ascii0,但是我这里(gcc)和ide都不是啊

#include<stdio.h>

char numbers[5][10][4] = {"XXX","..X","XXX","XXX","X.X","XXX","XXX","XXX","XXX","XXX","X.X","..X","..X","..X","X.X","X..","X..","..X","X.X","X.X","X.X","..X","XXX","XXX","XXX","XXX","XXX","..X","XXX","XXX","X.X","..X","X..","..X","..X","..X","X.X","..X","X.X","..X","XXX","..X","XXX","XXX","..X","XXX","XXX","..X","XXX","XXX"};

char out[400][5] ;

int main()
{
    //puts("#EFE$FW$");
    int i,j,k,n;
    int temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        temp=getchar();
        if(temp=='\n'){i--;continue;}
        temp -='0';
        //printf("%d ",temp);
        //temp = getchar()-'0';
        for(j=0;j<3;j++)
            for(k=0;k<5;k++)
                out[i*4+j][k]=numbers[k][temp][j];
        for(j=0;j<5;j++)
            out[i*4+3][j]='.';
    }
    for(i=0;i<5;i++){
        for(j=0;j<4*n-1;j++)
            printf("%c",out[j][i]);
        putchar('\n');
    }
    return 0;
}

by qwq_it_is_me @ 2021-04-02 22:13:56

问题已解决。

问题在这次的输入文本里,回车是\r\n。。。 把

if(temp=='\n'){i--;continue;}

改成

if(temp=='\n'||temp=='\r){i--;continue;}

即可解决(就是怎么坑)


by chaoscodes @ 2021-04-12 19:26:52

@qwq_it_is_me 没想到真的是官网问题。。


|