WA并且说第一行第一列是ASCII0求助

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

Tang__Bin @ 2023-07-09 08:55:33

本地没发现问题,但是提交后0分。。。

using namespace std;
#include<iostream>
void GetLine(char* buf)
{
    char ch = getchar();
    while (ch == '\n')ch = getchar();
    for (; ch != '\n'; ch = getchar())*buf++ = ch;
    *buf = 0;
}
const char* ss[5] = 
{
    "XXX..XXXXXXXX.XXXXXXXXXXXXXXXX" ,
    "X.X..X..X..XX.XX..X....XX.XX.X" ,
    "X.X..XXXXXXXXXXXXXXXX..XXXXXXX" ,
    "X.X..XX....X..X..XX.X..XX.X..X" ,
    "XXX..XXXXXXX..XXXXXXX..XXXXXXX" 
};
char s[10010];
short arr[10010];
int main()
{
    int n; cin >> n;
    GetLine(s);
    for (int i = 0; i < n; i++) { arr[i] = s[i] - '0';}
    //cout << endl;
    int num = 0;
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < n - 1; j++)
        {
            for (int k = 0; k < 3; k++)putchar(ss[i][3 * arr[j] + k]);
            putchar('.');
        }
        for (int k = 0; k < 3; k++)putchar(ss[i][3 * arr[n - 1] + k]);
        putchar(10);
    }

    return 0;
}

|