全WA求助

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

mimangdetongluoshao @ 2023-08-01 13:23:40

全过

全WA

啊啊啊啊

大佬求助!!!

代码见下:


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define S 110
int main(void){
    int n;
    scanf("%d",&n);
    char num[S];
    for(int i=0;i<=n;i++){
        scanf("%c",&num[i]);
    }

    for(int i=0;i<=n;i++){
        if(num[i]=='0'){
            printf("XXX");
        }
        else if(num[i]=='1'){
            printf("..X");
        }
        else if(num[i]=='2'){
            printf("XXX");
        }
        else if(num[i]=='3'){
            printf("XXX");
        }
        else if(num[i]=='4'){
            printf("X.X");
        }
        else if(num[i]=='5'){
            printf("XXX");
        }
        else if(num[i]=='6'){
            printf("XXX");
        }
        else if(num[i]=='7'){
            printf("XXX");
        }
        else if(num[i]=='8'){
            printf("XXX");
        }
        else if(num[i]=='9'){
            printf("XXX");
        }
        else{}
        if(i!=n&&i!=0){
            printf(".");
        }
    }
    printf("\n");
    for(int i=0;i<=n;i++){
        if(num[i]=='0'){
            printf("X.X");
        }
        else if(num[i]=='1'){
            printf("..X");
        }
        else if(num[i]=='2'){
            printf("..X");
        }
        else if(num[i]=='3'){
            printf("..X");
        }
        else if(num[i]=='4'){
            printf("X.X");
        }
        else if(num[i]=='5'){
            printf("X..");
        }
        else if(num[i]=='6'){
            printf("X..");
        }
        else if(num[i]=='7'){
            printf("..X");
        }
        else if(num[i]=='8'){
            printf("X.X");
        }
        else if(num[i]=='9'){
            printf("X.X");
        }
        else{}
        if(i!=n&&i!=0){
            printf(".");
        }
    }
    printf("\n");
    for(int i=0;i<=n;i++){
        if(num[i]=='0'){
            printf("X.X");
        }
        else if(num[i]=='1'){
            printf("..X");
        }
        else if(num[i]=='2'){
            printf("XXX");
        }
        else if(num[i]=='3'){
            printf("XXX");
        }
        else if(num[i]=='4'){
            printf("XXX");
        }
        else if(num[i]=='5'){
            printf("XXX");
        }
        else if(num[i]=='6'){
            printf("XXX");
        }
        else if(num[i]=='7'){
            printf("..X");
        }
        else if(num[i]=='8'){
            printf("XXX");
        }
        else if(num[i]=='9'){
            printf("XXX");
        }
        else{}

        if(i!=n&&i!=0){
            printf(".");
        }
        }
    printf("\n");
    for(int i=0;i<=n;i++){
        if(num[i]=='0'){
            printf("X.X");
        }
        else if(num[i]=='1'){
            printf("..X");
        }
        else if(num[i]=='2'){
            printf("X..");
        }
        else if(num[i]=='3'){
            printf("..X");
        }
        else if(num[i]=='4'){
            printf("..X");
        }
        else if(num[i]=='5'){
            printf("..X");
        }
        else if(num[i]=='6'){
            printf("X.X");
        }
        else if(num[i]=='7'){
            printf("..X");
        }
        else if(num[i]=='8'){
            printf("X.X");
        }
        else if(num[i]=='9'){
            printf("..X");
        }
        else{}
        if(i!=n&&i!=0){
            printf(".");
        }
    }
    printf("\n");
    for(int i=0;i<=n;i++){
        if(num[i]=='0'){
            printf("XXX");
        }
        else if(num[i]=='1'){
            printf("..X");
        }
        else if(num[i]=='2'){
            printf("XXX");
        }
        else if(num[i]=='3'){
            printf("XXX");
        }
        else if(num[i]=='4'){
            printf("..X");
        }
        else if(num[i]=='5'){
            printf("XXX");
        }
        else if(num[i]=='6'){
            printf("XXX");
        }
        else if(num[i]=='7'){
            printf("..X");
        }
        else if(num[i]=='8'){
            printf("XXX");
        }
        else if(num[i]=='9'){
            printf("XXX");
        }
        else{}
        if(i!=n&&i!=0){
            printf(".");
        }
    }

    return 0;}

by LinGxIao_0230 @ 2023-08-01 13:32:06

#include<bits/stdc++.h>
using namespace std;
string s0_1="XXX",s0_2="X.X",s0_3="X.X",s0_4="X.X",s0_5="XXX";
string s1_1="..X",s1_2="..X",s1_3="..X",s1_4="..X",s1_5="..X";
string s2_1="XXX",s2_2="..X",s2_3="XXX",s2_4="X..",s2_5="XXX";
string s3_1="XXX",s3_2="..X",s3_3="XXX",s3_4="..X",s3_5="XXX";
string s4_1="X.X",s4_2="X.X",s4_3="XXX",s4_4="..X",s4_5="..X";
string s5_1="XXX",s5_2="X..",s5_3="XXX",s5_4="..X",s5_5="XXX";
string s6_1="XXX",s6_2="X..",s6_3="XXX",s6_4="X.X",s6_5="XXX";
string s7_1="XXX",s7_2="..X",s7_3="..X",s7_4="..X",s7_5="..X";
string s8_1="XXX",s8_2="X.X",s8_3="XXX",s8_4="X.X",s8_5="XXX";
string s9_1="XXX",s9_2="X.X",s9_3="XXX",s9_4="..X",s9_5="XXX";
int n;
string st;
int main()
{
    cin>>n>>st;
    for(int i=0;i<n;i++)
    {
        if(st[i]=='0') cout<<s0_1;
        else if(st[i]=='1') cout<<s1_1;
        else if(st[i]=='2') cout<<s2_1;
        else if(st[i]=='3') cout<<s3_1;
        else if(st[i]=='4') cout<<s4_1;
        else if(st[i]=='5') cout<<s5_1;
        else if(st[i]=='6') cout<<s6_1;
        else if(st[i]=='7') cout<<s7_1;
        else if(st[i]=='8') cout<<s8_1;
        else if(st[i]=='9') cout<<s9_1;
        if(i!=n-1) cout<<'.';
    }
    cout<<endl;
    for(int i=0;i<n;i++)
    {
        if(st[i]=='0') cout<<s0_2;
        else if(st[i]=='1') cout<<s1_2;
        else if(st[i]=='2') cout<<s2_2;
        else if(st[i]=='3') cout<<s3_2;
        else if(st[i]=='4') cout<<s4_2;
        else if(st[i]=='5') cout<<s5_2;
        else if(st[i]=='6') cout<<s6_2;
        else if(st[i]=='7') cout<<s7_2;
        else if(st[i]=='8') cout<<s8_2;
        else if(st[i]=='9') cout<<s9_2;
        if(i!=n-1) cout<<'.';
    }
    cout<<endl;
    for(int i=0;i<n;i++)
    {
        if(st[i]=='0') cout<<s0_3;
        else if(st[i]=='1') cout<<s1_3;
        else if(st[i]=='2') cout<<s2_3;
        else if(st[i]=='3') cout<<s3_3;
        else if(st[i]=='4') cout<<s4_3;
        else if(st[i]=='5') cout<<s5_3;
        else if(st[i]=='6') cout<<s6_3;
        else if(st[i]=='7') cout<<s7_3;
        else if(st[i]=='8') cout<<s8_3;
        else if(st[i]=='9') cout<<s9_3;
        if(i!=n-1) cout<<'.';
    }
    cout<<endl;
    for(int i=0;i<n;i++)
    {
        if(st[i]=='0') cout<<s0_4;
        else if(st[i]=='1') cout<<s1_4;
        else if(st[i]=='2') cout<<s2_4;
        else if(st[i]=='3') cout<<s3_4;
        else if(st[i]=='4') cout<<s4_4;
        else if(st[i]=='5') cout<<s5_4;
        else if(st[i]=='6') cout<<s6_4;
        else if(st[i]=='7') cout<<s7_4;
        else if(st[i]=='8') cout<<s8_4;
        else if(st[i]=='9') cout<<s9_4;
        if(i!=n-1) cout<<'.';
    }
    cout<<endl;
    for(int i=0;i<n;i++)
    {
        if(st[i]=='0') cout<<s0_5;
        else if(st[i]=='1') cout<<s1_5;
        else if(st[i]=='2') cout<<s2_5;
        else if(st[i]=='3') cout<<s3_5;
        else if(st[i]=='4') cout<<s4_5;
        else if(st[i]=='5') cout<<s5_5;
        else if(st[i]=='6') cout<<s6_5;
        else if(st[i]=='7') cout<<s7_5;
        else if(st[i]=='8') cout<<s8_5;
        else if(st[i]=='9') cout<<s9_5;
        if(i!=n-1) cout<<'.';
    }
    return 0;
}

|