在本地感觉是一样的,但是全wa

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

wansaa @ 2022-11-15 09:47:35

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    getchar();
    char num[n];
    for(int i=0;i<n;i++)
    {
        scanf("%c",&num[i]);
    }
//  getchar();
    char ch1[10][4]={"XXX","..X","XXX","XXX","X.X","XXX","XXX","XXX","XXX","XXX"};
    char ch2[10][4]={"X.X","..X","..X","..X","X.X","X..","X..","..X","X.X","X.X"};
    char ch3[10][4]={"X.X","..X","XXX","XXX","XXX","XXX","XXX","..X","XXX","XXX"};
    char ch4[10][4]={"X.X","..X","X..","..X","..X","..X","X.X","..X","X.X","..X"};  
    char ch5[10][4]={"XXX","..X","XXX","XXX","..X","XXX","XXX","..X","XXX","XXX"};
    for(int i=0;i<n;i++)
    {
        printf("%s",ch1[num[i]-'0']);
        if(i!=n-1)
        {
            printf(".");
        }
    }
    putchar('\n');
        for(int i=0;i<n;i++)
    {
        printf("%s",ch2[num[i]-'0']);
        if(i!=n-1)
        {
            printf(".");
        }
    }
    putchar('\n');
        for(int i=0;i<n;i++)
    {
        printf("%s",ch3[num[i]-'0']);
        if(i!=n-1)
        {
            printf(".");
        }
    }
    putchar('\n');
        for(int i=0;i<n;i++)
    {
        printf("%s",ch4[num[i]-'0']);
        if(i!=n-1)
        {
            printf(".");
        }
    }
    putchar('\n');
        for(int i=0;i<n;i++)
    {
        printf("%s",ch5[num[i]-'0']);
        if(i!=n-1)
        {
            printf(".");
        }
    }
    return 0;
}

by yummy @ 2022-11-15 10:05:01

@wansaa 慎用 getchar(),建议还是直接 scanf("%s",num);


by wansaa @ 2022-11-15 16:20:24

@yummy 谢谢大佬;已解决


|