求助

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

新时代卷王 @ 2021-10-03 08:40:04

#include<bits/stdc++.h>
using namespace std;
char arr[100];
string show0[5];
string show1[5];
string show2[5];
string show3[5];
string show4[5];
string show5[5];
string show6[5];
string show7[5];
string show8[5];
string show9[5];
string ans[5];
int main()
{
    show0[0] = show0[4] = show2[0] = show2[2]=show2[4] = show3[0] = show3[2] = show3[4] = show4[2] = show5[0] = show5[2] = show5[4] = show6[0] = show6[2] = show6[4] = show7[0] = show8[0] = show8[2] = show8[4] = show9[0] = show9[2] = show9[4] = "XXX.";
    show1[0] = show1[1] = show1[2] = show1[3] = show1[4] = show2[1] = show3[1] = show3[3] = show4[3] = show4[4] = show5[3] = show7[1] = show7[2] = show7[3] = show7[4] = show9[3] = "..X.";
    show2[3] = show5[1] = show6[1] = "X...";
    show0[1]=show0[2]=show0[3]=show4[0] = show4[1] = show6[3] = show8[1] = show8[3] = show9[1] = "X.X.";
    int n = 0;
    cin >> n;
    getchar();
    for (int i = 0; i < n; i++)
    {
        arr[i] = getchar();
    }

    for (int k = 0; k < 5; k++)
    {
        for (int j = 0; j < n; j++)
        {
            switch (arr[j])
            {
            case '0':
                ans[k] += show0[k];
                break;
            case '1':
                ans[k] += show1[k];
                break;
            case '2':
                ans[k] += show2[k];
                break;
            case '3':
                ans[k] += show3[k];
                break;
            case '4':
                ans[k] += show4[k];
                break;
            case '5':
                ans[k] += show5[k];
                break;
            case '6':
                ans[k] += show6[k];
                break;
            case '7':
                ans[k] += show7[k];
                break;
            case '8':
                ans[k] += show8[k];
                break;
            case '9':
                ans[k] += show9[k];
                break;
            default:
                break;
            }

        }

    }

    for (int l = 0; l < 5; l++)
    {

            ans[l] = ans[l].substr(0, ans[l].length() - 1);

        cout << ans[l] << endl;

    }

    return 0;
}

本地可过,在这0分


|