本地似乎没问题,但是全WA求助qwq

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

bigsaltyfish @ 2022-10-23 13:14:32

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%*c");
    char *a = (char*) malloc ((n+1)*sizeof(char));
    for(int i=0;i<n;i++){
        scanf("%c",&a[i]);
        a[i]-='0';
    }

    int b[10][5][3]={
                    1,1,1,1,0,1,1,0,1,1,0,1,1,1,1,
                    0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,
                    1,1,1,0,0,1,1,1,1,1,0,0,1,1,1,
                    1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,
                    1,0,1,1,0,1,1,1,1,0,0,1,0,0,1,
                    1,1,1,1,0,0,1,1,1,0,0,1,1,1,1,
                    1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,
                    1,1,1,0,0,1,0,0,1,0,0,1,0,0,1,
                    1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,
                    1,1,1,1,0,1,1,1,1,0,0,1,1,1,1
                    };

    int i,j,k;
    for(j=0;j<5;j++){
        for(i=0;i<n;i++){
            for(k=0;k<3;k++){
                if(b[a[i]][j][k]){
                    printf("X");
                }else{
                    printf(".");
                }
            }   
            if(i!=n-1)printf(".");  
        }
        if(j!=4)printf("\n");
    }       
    return 0;
}

|