全wa了,自己试了一个测试点是对了也wa

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

hongqiuqiuqiu @ 2022-11-17 21:13:46

#include<bits/stdc++.h>
#include<string>
using namespace std;
char num[10][20]={"XXXX.XX.XX.XXXX","..X..X..X..X..X","XXX..XXXX..XXX","XXX..XXXX..XXXX","X.XX.XXXX..X..X","XXXX..XXX..XXXX","XXXX..XXXX.XXXX","XXX..X..X..X..X","XXXX.XXXXX.XXXX","XXXX.XXXX..XXXX"};
int main()
{
    int n,a[110]={0};
    char b[110],t;
    scanf("%d",&n);
    scanf("%c",&t); 
    for(int i=1;i<=n;i++)
    {
        scanf("%c",&b[i]);
        a[i]=b[i]-'0'; 
    }
    for(int i=1;i<=5;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=(i-1)*3;k<=i*3-1;k++)
                printf("%c",num[a[j]][k]);
            if(j!=n)
                putchar('.'); 
        }
        if(i!=5)
            putchar('\n');
    }
}

by mmh08100566 @ 2022-11-17 21:29:29

请试试这组Hack

3
123

by hongqiuqiuqiu @ 2022-11-17 22:28:48

改了,还是错了


by hongqiuqiuqiu @ 2022-11-17 22:29:25

#include<bits/stdc++.h>
#include<string>
using namespace std;
char num[10][20]={"XXXX.XX.XX.XXXX","..X..X..X..X..X","XXX..XXXXX..XXX","XXX..XXXX..XXXX","X.XX.XXXX..X..X","XXXX..XXX..XXXX","XXXX..XXXX.XXXX","XXX..X..X..X..X","XXXX.XXXXX.XXXX","XXXX.XXXX..XXXX"};
int main()
{
    int n,a[110]={0};
    char b[110],t;
    scanf("%d",&n);
    scanf("%c",&t); 
    for(int i=1;i<=n;i++)
    {
        scanf("%c",&b[i]);
        a[i]=b[i]-'0'; 
    }
    for(int i=1;i<=5;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=(i-1)*3;k<=i*3-1;k++)
                printf("%c",num[a[j]][k]);
            if(j!=n)
                putchar('.'); 
        }
        if(i!=5)
            putchar('\n');
    }
}

by IamCXK @ 2023-01-30 14:40:21

输入文件中的换行末尾可能是'\n''\r',而不是'\n'


|