求救!!!

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

yaoyurt @ 2024-10-17 18:21:41

救救孩子吧,没看出来哪里有问题但是零分555555```cpp


#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    const char* num[10][5];
    num[0][0] = "XXX";
    num[0][1] = "X.X";
    num[0][2] = "X.X";
    num[0][3] = "X.X";
    num[0][4] = "XXX";
    num[1][0] = "..X";
    num[1][1] = "..X";
    num[1][2] = "..X";
    num[1][3] = "..X";
    num[1][4] = "..X";
    num[2][0] = "XXX";
    num[2][1] = "..X";
    num[2][2] = "XXX";
    num[2][3] = "X..";
    num[2][4] = "XXX";
    num[3][0] = "XXX";
    num[3][1] = "..X";
    num[3][2] = "XXX";
    num[3][3] = "..X";
    num[3][4] = "XXX";
    num[4][0] = "X.X";
    num[4][1] = "X.X";
    num[4][2] = "XXX";
    num[4][3] = "..X";
    num[4][4] = "..X";
    num[5][0] = "XXX";
    num[5][1] = "X..";
    num[5][2] = "XXX";
    num[5][3] = "..X";
    num[5][4] = "XXX";
    num[6][0] = "XXX";
    num[6][1] = "X..";
    num[6][2] = "XXX";
    num[6][3] = "X.X";
    num[6][4] = "XXX";
    num[7][0] = "XXX";
    num[7][1] = "..X";
    num[7][2] = "..X";
    num[7][3] = "..X";
    num[7][4] = "..X";
    num[8][0] = "XXX";
    num[8][1] = "X.X";
    num[8][2] = "XXX";
    num[8][3] = "X.X";
    num[8][4] = "XXX";
    num[9][0] = "XXX";
    num[9][1] = "X.X";
    num[9][2] = "XXX";
    num[9][3] = "..X";
    num[9][4] = "XXX";
    int n;
    (cin >> n).get();
    string dig;
    getline(cin,dig);
    vector<int> a(n) ;
    for (int i = 0; i < dig.size(); i++)
        a[i] = dig[i]-'0';
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < a.size(); j++) {
            cout << num[a[j]][i];
            if (j != n - 1)
                cout << ".";
        }
        cout << endl;
    }
    return 0;
}

by I_AM_Nigger @ 2024-10-17 19:03:16

#include<bits/stdc++.h>
using namespace std;
int a[110];
char num[10][5][3]=
{
    {
        'X','X','X',
        'X','.','X',
        'X','.','X',
        'X','.','X',
        'X','X','X',
    },
    {
        '.','.','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
    },
    {
        'X','X','X',
        '.','.','X',
        'X','X','X',
        'X','.','.',
        'X','X','X',
    },
    {
        'X','X','X',
        '.','.','X',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    },
    {
        'X','.','X',
        'X','.','X',
        'X','X','X',
        '.','.','X',
        '.','.','X',
    },
    {
        'X','X','X',
        'X','.','.',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    },
    {
        'X','X','X',
        'X','.','.',
        'X','X','X',
        'X','.','X',
        'X','X','X',
    },
    {
        'X','X','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
        '.','.','X',
    },
    {
        'X','X','X',
        'X','.','X',
        'X','X','X',
        'X','.','X',
        'X','X','X',
    },
    {
        'X','X','X',
        'X','.','X',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    }
};
int main()
{
    int n;
    cin >> n;
    for(int i = 0;i<n;i++)
    {
        scanf("%1d",&a[i]);
    }
    for(int i= 0;i<5;i++)
    {
        for(int j = 0;j<n;j++)
        {
            for(int k = 0;k<3;k++)
            {
                cout << num[a[j]][i][k];
            }
            if(j != n-1)
            {
                cout << '.';                
            }
        }
        cout << '\n';
    }
    return 0;
}

我也没看出啥问题,你用我这个看看,可能是你输出格式有问题?


by I_AM_Nigger @ 2024-10-17 19:07:11

@yaoyurt 你这代码没问题啊!!,你看看我的再看下


by yaoyurt @ 2024-10-17 21:15:26

@I_AM_Nigger 我这代码提交全wa,我也很好奇原因


by milk2715093695 @ 2024-10-22 18:49:08

看看是不是这个问题?

链接


by yaoyurt @ 2024-10-31 09:46:32

@milk2715093695 我把getline直接换成cin>>就ac了


|