C++下载样例在本地输出正确,评测机硬是不通过

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

LiuChip @ 2024-11-12 11:02:31

我同一份代码提交了两三次,每次wa的地方都不一样 例如第一次是line1 colume1 read ., expected X 第二次则是line1 colume3 read., expected X 但是我下载了样例进行输入输出都是正确的


#include<iostream>
#include<cstring>
using namespace std;
int transform(char ch)
{
    if (ch == '1') return 1;
    if (ch == '2') return 2;
    if (ch == '3') return 3;
    if (ch == '4') return 4;
    if (ch == '5') return 5;
    if (ch == '6') return 6;
    if (ch == '7') return 7;
    if (ch == '8') return 8;
    if (ch == '9') return 9;
    if (ch == '0') return 0;
}
int main()
{
    int num;
    cin >> num;
    string s[5];
    for (int i = 0; i < num + 1; i++)
    {
        char ch;
        ch = getchar();
        if (ch == '\n')continue;
        if (transform(ch) == 0)
        {
            s[0] += "XXX";
            s[1] += "X.X";
            s[2] += "X.X";
            s[3] += "X.X";
            s[4] += "XXX";
        }
        else if (transform(ch) == 1)
        {
            s[0] += "..X";
            s[1] += "..X";
            s[2] += "..X";
            s[3] += "..X";
            s[4] += "..X";
        }
        else if (transform(ch) == 2)
        {
            s[0] += "XXX";
            s[1] += "..X";
            s[2] += "XXX";
            s[3] += "X..";
            s[4] += "XXX";
        }
        else if (transform(ch) == 3)
        {
            s[0] += "XXX";
            s[1] += "..X";
            s[2] += "XXX";
            s[3] += "..X";
            s[4] += "XXX";
        }
        else if (transform(ch) == 4)
        {
            s[0] += "X.X";
            s[1] += "X.X";
            s[2] += "XXX";
            s[3] += "..X";
            s[4] += "..X";
        }
        else if (transform(ch) == 5)
        {
            s[0] += "XXX";
            s[1] += "X..";
            s[2] += "XXX";
            s[3] += "..X";
            s[4] += "XXX";
        }
        else if (transform(ch) == 6)
        {
            s[0] += "XXX";
            s[1] += "X..";
            s[2] += "XXX";
            s[3] += "X.X";
            s[4] += "XXX";
        }
        else if (transform(ch) == 7)
        {
            s[0] += "XXX";
            s[1] += "..X";
            s[2] += "..X";
            s[3] += "..X";
            s[4] += "..X";
        }
        else if (transform(ch) == 8)
        {
            s[0] += "XXX";
            s[1] += "X.X";
            s[2] += "XXX";
            s[3] += "X.X";
            s[4] += "XXX";
        }
        else if (transform(ch) == 9)
        {
            s[0] += "XXX";
            s[1] += "X.X";
            s[2] += "XXX";
            s[3] += "..X";
            s[4] += "XXX";
        }
        if (i == num)break;
        s[0] += ".";
        s[1] += ".";
        s[2] += ".";
        s[3] += ".";
        s[4] += ".";
    }
    for (int i = 0; i < 5; i++)
    {
        cout << s[i] << endl;
    }
    return 0;
}

by I_Love_Codm @ 2024-11-16 15:06:52

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

string str1[10] = {"XXX", "..X", "XXX", "XXX", "X.X", "XXX", "XXX", "XXX", "XXX", "XXX"};
string str2[10] = {"X.X", "..X", "..X", "..X", "X.X", "X..", "X..", "..X", "X.X", "X.X"};
string str3[10] = {"X.X", "..X", "XXX", "XXX", "XXX", "XXX", "XXX", "..X", "XXX", "XXX"};
string str4[10] = {"X.X", "..X", "X..", "..X", "..X", "..X", "X.X", "..X", "X.X", "..X"};
string str5[10] = {"XXX", "..X", "XXX", "XXX", "..X", "XXX", "XXX", "..X", "XXX", "XXX"};

string str;
void out(string s[]){
    cout << s[str[0] - '0'];
    for(int i = 1; i < str.size(); i++) cout  << '.'<< s[str[i] - '0'];
    cout << endl;
}

int main(){
    int n;
    cin >> n >> str;

    out(str1);
    out(str2);
    out(str3);
    out(str4);
    out(str5);
    return 0;
}

将每个数字拆成五行,每一行打表输出就行了


|