请问为什么是0分

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

Nidhogg4526 @ 2021-04-03 21:19:37


#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    int a[100];
    int an;
    int flag;
    string k[10][5];
    k[0][0]="XXX";
    k[0][1]="X.X";
    k[0][2]="X.X";
    k[0][3]="X.X";
    k[0][4]="XXX";

    k[1][0]="..X";
    k[1][1]="..X";
    k[1][2]="..X";
    k[1][3]="..X";
    k[1][4]="..X";

    k[2][0]="XXX";
    k[2][1]="..X";
    k[2][2]="XXX";
    k[2][3]="X..";
    k[2][4]="XXX";

    k[3][0]="XXX";
    k[3][1]="..X";
    k[3][2]="XXX";
    k[3][3]="..X";
    k[3][4]="XXX";

    k[4][0]="X.X";
    k[4][1]="X.X";
    k[4][2]="XXX";
    k[4][3]="..X";
    k[4][4]="..X";

    k[5][0]="XXX";
    k[5][1]="X..";
    k[5][2]="XXX";
    k[5][3]="..X";
    k[5][4]="XXX";

    k[6][0]="XXX";
    k[6][1]="X..";
    k[6][2]="XXX";
    k[6][3]="X.X";
    k[6][4]="XXX";

    k[7][0]="XXX";
    k[7][1]="..X";
    k[7][2]="..X";
    k[7][3]="..X";
    k[7][4]="..X";

    k[8][0]="XXX";
    k[8][1]="X.X";
    k[8][2]="XXX";
    k[8][3]="X.X";
    k[8][4]="XXX";

    k[9][0]="XXX";
    k[9][1]="X.X";
    k[9][2]="XXX";
    k[9][3]="..X";
    k[9][4]="XXX";

    cin>>an;
    cin>>flag;
    int l=an-1;
    while(l!=-1)
    {
        a[l]=flag%10;
        l--;
        flag/=10;
    }
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<an;j++)
        {
            cout<<k[a[j]][i];
            cout<<".";
        }
        cout<<endl;
    }
    return 0;
}

by yekgg @ 2021-04-03 21:21:51

@Nidhogg4526 =666=

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
char W[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',
    },
    {//9
        'X','X','X',
        'X','.','X',
        'X','X','X',
        '.','.','X',
        'X','X','X',
    }
};
int n;
char s[110];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<5;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<3;k++){
                cout<<W[s[j]-'0'][i][k];
            }
            if(j!=n-1) cout<<'.';
        }
        cout<<endl;
    }
    return 0;
}

by 青莲梵音 @ 2021-04-14 20:40:48

不够暴力,看我的

#include<iostream>
#include<cstdio> 

using namespace std;
char ss[10][5][4];

int main()
{
    int n, i, j, num;
    char s[105];
    scanf("%d",&n);
    scanf("%s",s);
    sscanf("XXX\0","%s",ss[0][0]);
    sscanf("X.X\0","%s",ss[0][1]);
    sscanf("X.X\0","%s",ss[0][2]);
    sscanf("X.X\0","%s",ss[0][3]);
    sscanf("XXX\0","%s",ss[0][4]);
    sscanf("..X\0","%s",ss[1][0]);
    sscanf("..X\0","%s",ss[1][1]);
    sscanf("..X\0","%s",ss[1][2]);
    sscanf("..X\0","%s",ss[1][3]);
    sscanf("..X\0","%s",ss[1][4]);
    sscanf("XXX\0","%s",ss[2][0]);
    sscanf("..X\0","%s",ss[2][1]);
    sscanf("XXX\0","%s",ss[2][2]);
    sscanf("X..\0","%s",ss[2][3]);
    sscanf("XXX\0","%s",ss[2][4]);
    sscanf("XXX\0","%s",ss[3][0]);
    sscanf("..X\0","%s",ss[3][1]);
    sscanf("XXX\0","%s",ss[3][2]);
    sscanf("..X\0","%s",ss[3][3]);
    sscanf("XXX\0","%s",ss[3][4]);
    sscanf("X.X\0","%s",ss[4][0]);
    sscanf("X.X\0","%s",ss[4][1]);
    sscanf("XXX\0","%s",ss[4][2]);
    sscanf("..X\0","%s",ss[4][3]);
    sscanf("..X\0","%s",ss[4][4]);
    sscanf("XXX\0","%s",ss[5][0]);
    sscanf("X..\0","%s",ss[5][1]);
    sscanf("XXX\0","%s",ss[5][2]);
    sscanf("..X\0","%s",ss[5][3]);
    sscanf("XXX\0","%s",ss[5][4]);
    sscanf("XXX\0","%s",ss[6][0]);
    sscanf("X..\0","%s",ss[6][1]);
    sscanf("XXX\0","%s",ss[6][2]);
    sscanf("X.X\0","%s",ss[6][3]);
    sscanf("XXX\0","%s",ss[6][4]);
    sscanf("XXX\0","%s",ss[7][0]);
    sscanf("..X\0","%s",ss[7][1]);
    sscanf("..X\0","%s",ss[7][2]);
    sscanf("..X\0","%s",ss[7][3]);
    sscanf("..X\0","%s",ss[7][4]);
    sscanf("XXX\0","%s",ss[8][0]);
    sscanf("X.X\0","%s",ss[8][1]);
    sscanf("XXX\0","%s",ss[8][2]);
    sscanf("X.X\0","%s",ss[8][3]);
    sscanf("XXX\0","%s",ss[8][4]);
    sscanf("XXX\0","%s",ss[9][0]);
    sscanf("X.X\0","%s",ss[9][1]);
    sscanf("XXX\0","%s",ss[9][2]);
    sscanf("..X\0","%s",ss[9][3]);
    sscanf("XXX\0","%s",ss[9][4]);
    for (i = 0; i < 5; ++i)
    {
        int flag = 0;
        for (j = 0; j < n; ++j)
        {
            num = s[j] - '0';
            if (flag)
            {
                printf(".%s",ss[num][i]);
            }
            else if(!flag)
            {
                printf("%s",ss[num][i]);
            }
            flag = 1;
        }
        printf("\n");
    }
    return 0;
}

|