20分,数字都可以打出来,但还是20分

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

baibaobao666 @ 2023-04-01 12:46:01

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

string number[105];

string c(string n,int mod)//mod是第几行,n是数字
{
    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[i];
    }
    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;
}

真的不知道该怎么改了 啊啊啊啊啊啊啊啊啊啊啊啊啊啊


by Max6700 @ 2023-04-30 11:30:00

@baibaobao666 a,粗心不得了啊


上一页 |