样例对了,但是全错

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

cjy273386 @ 2023-11-05 14:46:35

#include<stdio.h>

int main (void) {
    char num[10][5][3]=
{
    {
        'X','X','X',
        'X','.','X',
        'X','.','X',
        'X','.','X',
        'X','X','X',
    },
    {
        '.','.','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
    },
    {
        'X','X','X',
        '.','.','X',
        'X','X','X',
        'X','.','.',
        'X','X','X',
    },
    {
        'X','X','X',
        '.','.','X',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    },
    {
        'X','.','X',
        'X','.','X',
        'X','X','X',
        '.','.','X',
        '.','.','X',
    },
    {
        'X','X','X',
        'X','.','.',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    },
    {
        'X','X','X',
        'X','.','.',
        'X','X','X',
        'X','.','X',
        'X','X','X',
    },
    {
        'X','X','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
    },
    {
        'X','X','X',
        'X','.','X',
        'X','X','X',
        'X','.','X',
        'X','X','X',
    },
    {
        'X','X','X',
        'X','.','X',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    }
    };
    int n;
    scanf("%d",&n);
    char c[n+1];
    for (int i=0;i<=n;i++){
        scanf("%c",&c[i]);
    }
    for (int i=0;i<5;i++){
        for (int j=1;j<=n;j++){
            for (int h=0;h<=2;h++){
                printf("%c",num[(int)(c[j]-'0')][i][h]);
            }
            if(j<n)
            printf(".");
        }
        printf("\n");
    }
    return 0;
}

求助大佬,问题出在哪真的


by jellyfaith @ 2023-11-05 14:56:37

忘加一列空格了,注意审题


by cjy273386 @ 2023-11-05 16:08:09

@jellyfaith 我有加啊,

if(j<n)
            printf(".");

这段代码就是加那一列间隔的啊 他那边报错是Wrong Answer.wrong answer On line 1 column 1, read (ASCII 0), expected X.


by xpppg @ 2023-11-19 17:19:32

@cjy273386 把scanf("%d",&n);改为scanf("%d ",&n); for (int i=0;i<=n;i++){ scanf("%c",&c[i]); }中的n改为n-1, 其他涉及n的地方也做相应的改动,再提交一遍试试


by milk2715093695 @ 2023-11-22 23:14:27

https://www.luogu.com.cn/discuss/735482 应该是一样的问题,可以去看看。


|