求助,c++明明本地输出全对,但全红

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

hkl_kl @ 2024-11-09 02:45:28

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

string x__ = "x..";
string x_x = "x.x";
string xxx = "xxx";
string __x = "..x";

string a1[5] = { __x,__x,__x,__x,__x };
string a2[5] = { xxx,__x,xxx,x__,xxx };
string a3[5] = { xxx,__x,xxx,__x,xxx };
string a4[5] = { x_x,x_x,xxx,__x,__x };
string a5[5] = { xxx,x__,xxx,__x,xxx };
string a6[5] = { xxx,x__,xxx,x_x,xxx };
string a7[5] = { xxx,__x,__x,__x,__x };
string a8[5] = { xxx,x_x,xxx,x_x,xxx };
string a9[5] = { xxx,x_x,xxx,__x,xxx };
string a0[5] = { xxx,x_x,x_x,x_x,xxx };

int main()
{
    int a;
    string sh;
    cin >> a;
    int* s = new int[a];
    cin >> sh;
    char *b = new char[a];
    for (int i = 0; i < a; i++)
    {
        b[i] = sh[i];
        s[i] = sh[i] - '0';
    }
    for (int i = 0; i < 5; i++)
    {
        for (int z = 0; z < a; z++)
        {
            switch (s[z])
            {
            case 1:cout << a1[i];
                break;
            case 2:cout << a2[i];
                break;
            case 3:cout << a3[i];
                break;
            case 4:cout << a4[i];
                break;
            case 5:cout << a5[i];
                break;
            case 6:cout << a6[i];
                break;
            case 7:cout << a7[i];
                break;
            case 8:cout << a8[i];
                break;
            case 9:cout << a9[i];
                break;
            case 0:cout << a0[i];
                break;
            }
            if (z != a - 1)
            {
                cout << ".";
            }
        }
        cout << endl;
    }

}

by tj2024 @ 2024-11-09 20:47:09

@hkl_kl 换成大写X试试(手动狗头)


by hkl_kl @ 2024-11-09 22:39:30

@tj2024 解决了,这个原因真绷不住


|