求助,输出一样但0分

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

huanglan @ 2022-10-04 21:29:05

/为什么是0分哇,输出看着一模一样/

#include<stdio.h>
#include<math.h>
int n,i,j,t;
int a[5][399];
int main(){
    scanf("%d",&n);
    for(i=0;i<5;i++){
        for(j=0;j<4*n-1;j++){
            a[i][j]='.';
        }
    }
    getchar();
    for(j=0;j<n;j++){
        t=getchar();
        t-='0'; 
        i=4*j;
        switch(t){
            case 0:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i]=a[1][i+2]=a[2][i]=a[2][i+2]=a[3][i]=a[3][i+2]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
            case 1:a[0][i+2]=a[1][i+2]=a[2][i+2]=a[3][i+2]=a[4][i+2]='X'; break;
            case 2:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i+2]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
            case 3:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i+2]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i+2]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
            case 4:a[0][i]=a[0][i+2]=a[1][i]=a[1][i+2]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i+2]=a[4][i+2]='X'; break;
            case 5:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i+2]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
            case 6:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i]=a[3][i+2]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
            case 7:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i+2]=a[2][i+2]=a[3][i+2]=a[4][i+2]='X'; break;
            case 8:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i]=a[1][i+2]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i]=a[3][i+2]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
            case 9:a[0][i]=a[0][i+1]=a[0][i+2]=a[1][i]=a[1][i+2]=a[2][i]=a[2][i+1]=a[2][i+2]=a[3][i+2]=a[4][i]=a[4][i+1]=a[4][i+2]='X'; break;
        }
    }
    for(i=0;i<5;i++){
        for(j=0;j<4*n-1;j++){
            printf("%c",a[i][j]);
        }
        printf("\n");           
    }
    return 0;

} 

by jnyz2021109122116 @ 2022-10-05 13:30:25

@huanglan 12行多加一个getchar();


by jnyz2021109122116 @ 2022-10-05 13:35:35

linux和Win的换行符不一样,下回先在洛谷IDE上跑一下


by huanglan @ 2022-10-05 15:06:39

@jnyz2021109122116 删除之后还是0分


by jnyz2021109122116 @ 2022-10-05 15:10:45

@huanglan 我意思是需要两个getchar,没说清楚哈哈


by jscsjg @ 2023-01-18 18:20:33

666


|