本地编译器过样例,但是全部RE

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

peterqiu @ 2023-02-01 19:33:26

求大佬指导

#include<iostream>
using namespace std;
int a[105];
string b1[10] = {
    "XXX","..X","XXX","XXX","X.X","XXX","XXX","XXX","XXX","XXX"
};
string b2[10] = {
    "X.X","..X","..X","..X","X.X","X..","X..","..X","X.X","X.X"
};
string b3[10] = {
    "X.X","..X","XXX","XXX","XXX","XXX","XXX","..X","XXX","XXX"
};
string b4[10] = {
    "X.X","..X","X..","..X","..X","..X","X.X","..X","X.X","..X"
};
string b5[10] = {
    "XXX","..X","XXX","XXX","..X","XXX","XXX","..X","XXX","XXX"
};
int main() {
    int n;
    char c;
    cin >> n;
    getchar();
    for (int i = 0;i < n;++i) {
        c = getchar();
        a[i] = (int)c - '0';
    }
    //cout << a[0];
    for (int i = 0;i < n;++i) {
        cout << b1[a[i]];
        if (i < n - 1)cout << ".";
        else cout << endl;
    }
    for (int i = 0;i < n;++i) {
        cout << b2[a[i]];
        if (i < n - 1)cout << ".";
        else cout << endl;
    }
    for (int i = 0;i < n;++i) {
        cout << b3[a[i]];
        if (i < n - 1)cout << ".";
        else cout << endl;
    }
    for (int i = 0;i < n;++i) {
        cout << b4[a[i]];
        if (i < n - 1)cout << ".";
        else cout << endl;
    }
    for (int i = 0;i < n;++i) {
        cout << b5[a[i]];
        if (i < n - 1)cout << ".";
    }
    return 0;
}

by shiranai @ 2023-02-04 22:02:17

getchar();

这段代码要重复两次。

出题人输入的换行是CR+LF(\r\n),所以要用两个getchar()。

可以看看这个链接里面的测试点配置要求3。


|