自己测试没毛病啊。。为啥都是WA呢呜呜呜

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

duheru666 @ 2021-05-05 22:56:28

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);

    int n;
    char nums[100];
    char out[5][400];

    cin>>n;
    gets(nums);

    int y=0;

    for (int i=0;i<n;i++){
        if (nums[i]=='0'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            for (int j=1;j<=3;j++){
                out[j][y]=out[j][y+2]='X';
                out[j][y+1]='.';
            }
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='1'){
            for (int j=0;j<5;j++){
                out[j][y]=out[j][y+1]='.';
                out[j][y+2]='X';
            }
            y+=3;
        }else if(nums[i]=='2'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]=out[1][y+1]='.';out[1][y+2]='X';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]='X';out[3][y+1]=out[3][y+2]='.';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='3'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]=out[1][y+1]='.';out[1][y+2]='X';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+1]='.';out[3][y+2]='X';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='4'){
            for (int j=0;j<=1;j++){
                out[j][y]=out[j][y+2]='X';
                out[1][y+1]='.';
            }
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+1]='.';out[3][y+2]='X';
            out[4][y]=out[4][y+1]='.';out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='4'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]='X';out[1][y+1]=out[1][y+2]='.';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+1]='.';out[3][y+2]='X';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }else if (nums[i]=='5'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]='X';out[1][y+1]=out[1][y+2]='.';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+1]='.';out[3][y+2]='X';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;           
        }else if(nums[i]=='6'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]='X';out[1][y+1]=out[1][y+2]='.';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+2]='X';out[3][y+1]='.';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='7'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]=out[1][y+1]='.';out[1][y+2]='X';
            out[2][y]=out[2][y+1]='.';out[2][y+2]='X';
            out[3][y]=out[3][y+1]='.';out[3][y+2]='X';
            out[4][y]=out[4][y+1]='.';out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='8'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]=out[1][y+2]='X';out[1][y+1]='.';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+2]='X';out[3][y+1]='.';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }else if(nums[i]=='9'){
            out[0][y]=out[0][y+1]=out[0][y+2]='X';
            out[1][y]=out[1][y+2]='X';out[1][y+1]='.';
            out[2][y]=out[2][y+1]=out[2][y+2]='X';
            out[3][y]=out[3][y+1]='.';out[3][y+2]='X';
            out[4][y]=out[4][y+1]=out[4][y+2]='X';
            y+=3;
        }

        for (int j=0;j<5;j++){
            out[j][y]='.';
        }
        y++;
    }

    for (int i=0;i<5;i++){
        for (int j=0;j<y-1;j++){
            cout<<out[i][j];
        }
        cout<<endl;
    }

    return 0;
} 

by _caiji_ @ 2021-05-05 23:16:19

gets换cin/scanf


by love_saber @ 2021-05-06 10:32:16

在在线IDE上测测你就知道了


|