20分,求大佬

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

baibaobao666 @ 2023-03-05 10:43:49

#include <iostream>
#include <string>
using namespace std;

string number[105];

string c(string n,int mod)
{
    if(n == "0")
    {
        if(mod == 1 || mod == 5)
        return "XXX";
        if(mod == 2 || mod == 3 || mod == 4)
        return "X.X";
    }
    if(n == "1")
    {
        return "..X";
    }
    if(n == "2")
    {
        if(mod == 1 || mod == 3 || mod == 5)
        return "XXX";
        if(mod == 2)
        return "..X";
        if(mod == 4)
        return "x..";
    }
    if(n == "3")
    {
        if(mod == 1 || mod == 3 || mod == 5)
        return "XXX";
        if(mod == 2 || mod == 4)
        return "..X";
    }
    if(n == "4")
    {
        if(mod == 1 || mod == 2)
        return "X.X";
        if(mod == 3)
        return "XXX";
        if(mod == 4 || mod == 5)
        return "..X";
    }
    if(n == "5")
    {
        if(mod == 1 || mod == 3 || mod == 5)
        return "XXX";
        if(mod == 4)
        return "..X";
        if(mod == 2)
        return "x..";
    }
    if(n == "6")
    {
        if(mod == 1 || mod == 3 || mod == 5)
        return "XXX";
        if(mod == 2)
        return "X..";
        if(mod == 4)
        return "x.x";
    }
    if(n == "7")
    {
        if(mod == 1)
        return "XXX";
        else
        return "..X";
    }
    if(n == "8")
    {
        if(mod == 1 || mod == 3 || mod == 5)
        return "XXX";
        else
        return "X.X";
    }
    if(n == "9")
    {
        if(mod == 1 || mod == 3 || mod == 5)
        return "XXX";
        if(mod == 2)
        return "X.X";
        else
        return "..X";
    }
}

int main()
{
    int a;
    cin >> a;
    string n;
    cin >> n;
    for(int i = 0;i <= a-1;i++)
    {
        number[i+1] = n.substr(i,1);
    }
    for(int i = 1;i <= 5;i++)
    {
        for(int j = 1;j <= a;j++)
        {
            cout << c(number[j],i);
            if(j != a)
            cout << ".";
        }
        cout << endl;
    }

    return 0;
}

|