C++全WA求助

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

TommyChen0429 @ 2024-09-19 10:45:44

#include<iostream>
using namespace std;
int main()
{
    char w[10][5][4]={
        {"XXX","X.X","X.X","X.X","XXX"},
        {"..X","..X","..X","..X","..X"},
        {"XXX","..X","XXX","X..","XXX"},
        {"XXX","..X","XXX","..X","XXX"},
        {"X.X","X.X","XXX","..X","..X"},
        {"XXX","X..","XXX","..X","XXX"},
        {"XXX","X..","XXX","X.X","XXX"},
        {"XXX","..X","..X","..X","..X"},
        {"XXX","X.X","XXX","X.X","XXX"},
        {"XXX","X.X","XXX","..X","XXX"}
    };
    int n;
    cin>>n;
    cin.get();
    char ch[101];
    cin.getline(ch,n+1);
    int a[101]={0};
    for(int i=0;i<n;i++)
    {
        a[i]=ch[i]-48;
    }
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<w[a[j]][i];
            if(j!=n-1)
                cout<<".";
        }
        cout<<endl;
    }
    return 0;
}

by LiuXuDong55555 @ 2024-09-23 19:52:38

@TommyChen0429

给你一个样例,去试试:

100
1234567891234567891234567891234567891234567891234567891234567891234567891234567891234567891234567891

by red369 @ 2024-09-26 20:27:16

问题
AC代码:

#include<iostream>
using namespace std;
int main()
{
    char w[10][5][4]={
        {"XXX","X.X","X.X","X.X","XXX"},
        {"..X","..X","..X","..X","..X"},
        {"XXX","..X","XXX","X..","XXX"},
        {"XXX","..X","XXX","..X","XXX"},
        {"X.X","X.X","XXX","..X","..X"},
        {"XXX","X..","XXX","..X","XXX"},
        {"XXX","X..","XXX","X.X","XXX"},
        {"XXX","..X","..X","..X","..X"},
        {"XXX","X.X","XXX","X.X","XXX"},
        {"XXX","X.X","XXX","..X","XXX"}
    };
    int n;
    cin>>n;
    char ch[101];
    cin>>ch;
    int a[101]={0};
    for(int i=0;i<n;i++)
    {
        a[i]=ch[i]-48;
    }
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<w[a[j]][i];
            if(j!=n-1)
                cout<<".";
        }
        cout<<endl;
    }
    return 0;
}

by red369 @ 2024-09-28 12:51:36

@TommyChen0429


by TommyChen0429 @ 2024-09-28 18:29:46

@red369 太感谢了,终于过了!!


|