和标准答案一模一样但是全部WA

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

Yungchit @ 2022-02-08 16:00:21

![]()![这是下载的第一个数据点的标准输出和我的答案的对比](C:\Users\27493\OneDrive\图片\屏幕快照)

```cpp
#include <iostream>

using namespace std;

int main()
{
    int n,k;
    scanf("%d",&n);
    n++;
    //cout<<n<<endl;
    char h[105];
    for(k=0;k<n;k++)
    {
        scanf("%c",&h[k]);
    }
    for(int i=0;i<5;i++)
    {
        switch(i)
        {
            case 0:
                for(int j=1;j<=n;j++)
                {
                    switch(h[j])
                    {
                    case '0':
                        printf("XXX");
                        break;
                    case '1':
                        printf("..X");
                        break;
                    case '2':
                        printf("XXX");
                        break;
                    case '3':
                        printf("XXX");
                        break;
                    case '4':
                        printf("X.X");
                        break;
                    case '5':
                        printf("XXX");
                        break;
                    case '6':
                        printf("XXX");
                        break;
                    case '7':
                        printf("XXX");
                        break;

                    case '8':
                        printf("XXX");
                        break;
                    case '9':
                        printf("XXX");
                        break;
                    }
                    if(j-n){printf((j==(n-1))?"":".");/*cout<<j;*/}
                }
                cout<<endl;
                break;
            case 1:
                for(int j=1;j<=n;j++)
                {
                    switch(h[j])
                    {
                    case '0':
                        printf("X.X");
                        break;
                    case '1':
                        printf("..X");
                        break;
                    case '2':
                        printf("..X");
                        break;
                    case '3':
                        printf("..X");
                        break;
                    case '4':
                        printf("X.X");
                        break;
                    case '5':
                        printf("X..");
                        break;
                    case '6':
                        printf("X..");
                        break;
                    case '7':
                        printf("..X");
                        break;

                    case '8':
                        printf("X.X");
                        break;
                    case '9':
                        printf("X.X");
                        break;
                    }
                    if(j-n){printf((j==(n-1))?"":".");/*cout<<j;*/}
                }
                cout<<endl;
                break;
            case 2:
                for(int j=1;j<=n;j++)
                {
                    switch(h[j])
                    {
                    case '0':
                        printf("X.X");
                        break;
                    case '1':
                        printf("..X");
                        break;
                    case '2':
                        printf("XXX");
                        break;
                    case '3':
                        printf("XXX");
                        break;
                    case '4':
                        printf("XXX");
                        break;
                    case '5':
                        printf("XXX");
                        break;
                    case '6':
                        printf("XXX");
                        break;
                    case '7':
                        printf("..X");
                        break;

                    case '8':
                        printf("XXX");
                        break;
                    case '9':
                        printf("XXX");
                        break;
                    }
                    if(j-n){printf((j==(n-1))?"":".");/*cout<<j;*/}
                }
                cout<<endl;
                break;
            case 3:
                for(int j=1;j<=n;j++)
                {
                    switch(h[j])
                    {
                    case '0':
                        printf("X.X");
                        break;
                    case '1':
                        printf("..X");
                        break;
                    case '2':
                        printf("X..");
                        break;
                    case '3':
                        printf("..X");
                        break;
                    case '4':
                        printf("..X");
                        break;
                    case '5':
                        printf("..X");
                        break;
                    case '6':
                        printf("X.X");
                        break;
                    case '7':
                        printf("..X");
                        break;

                    case '8':
                        printf("X.X");
                        break;
                    case '9':
                        printf("..X");
                        break;
                    }
                    if(j-n){printf((j==(n-1))?"":".");/*cout<<j;*/}
                }
                cout<<endl;
                break;
            case 4:
                for(int j=1;j<=n;j++)
                {
                    switch(h[j])
                    {
                    case '0':
                        printf("XXX");
                        break;
                    case '1':
                        printf("..X");
                        break;
                    case '2':
                        printf("XXX");
                        break;
                    case '3':
                        printf("XXX");
                        break;
                    case '4':
                        printf("..X");
                        break;
                    case '5':
                        printf("XXX");
                        break;
                    case '6':
                        printf("XXX");
                        break;
                    case '7':
                        printf("..X");
                        break;

                    case '8':
                        printf("XXX");
                        break;
                    case '9':
                        printf("XXX");
                        break;
                    }
                    if(j-n){printf((j==(n-1))?"":".");/*cout<<j;*/}
                }
                break;
        }
    }
    return 0;
}

by a1029 @ 2022-02-08 16:31:25

@Yungchit 我刚做了一下,AC了

我的代码:

#include <bits/stdc++.h>
using namespace std;

string ans[8];

int main()
{
    string s;
    cin >> s >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            ans[1] += "XXX";
            ans[2] += "X.X";
            ans[3] += "X.X";
            ans[4] += "X.X";
            ans[5] += "XXX";
        }
        if (s[i] == '1') {
            ans[1] += "..X";
            ans[2] += "..X";
            ans[3] += "..X";
            ans[4] += "..X";
            ans[5] += "..X";
        }
        if (s[i] == '2') {
            ans[1] += "XXX";
            ans[2] += "..X";
            ans[3] += "XXX";
            ans[4] += "X..";
            ans[5] += "XXX";
        }
        if (s[i] == '3') {
            ans[1] += "XXX";
            ans[2] += "..X";
            ans[3] += "XXX";
            ans[4] += "..X";
            ans[5] += "XXX";
        }
        if (s[i] == '4') {
            ans[1] += "X.X";
            ans[2] += "X.X";
            ans[3] += "XXX";
            ans[4] += "..X";
            ans[5] += "..X";
        }
        if (s[i] == '5') {
            ans[1] += "XXX";
            ans[2] += "X..";
            ans[3] += "XXX";
            ans[4] += "..X";
            ans[5] += "XXX";
        }
        if (s[i] == '6') {
            ans[1] += "XXX";
            ans[2] += "X..";
            ans[3] += "XXX";
            ans[4] += "X.X";
            ans[5] += "XXX";
        }
        if (s[i] == '7') {
            ans[1] += "XXX";
            ans[2] += "..X";
            ans[3] += "..X";
            ans[4] += "..X";
            ans[5] += "..X";
        }
        if (s[i] == '8') {
            ans[1] += "XXX";
            ans[2] += "X.X";
            ans[3] += "XXX";
            ans[4] += "X.X";
            ans[5] += "XXX";
        }
        if (s[i] == '9') {
            ans[1] += "XXX";
            ans[2] += "X.X";
            ans[3] += "XXX";
            ans[4] += "..X";
            ans[5] += "XXX";
        }
        ans[1] += ".";
        ans[2] += ".";
        ans[3] += ".";
        ans[4] += ".";
        ans[5] += ".";
    }
    for (int i = 1; i <= 5; i++) {
        for (int j = 0; j < ans[i].size() - 1; j++)
            cout << ans[i][j];
        cout << endl;
    }
    return 0;
}

by AlvinShen @ 2022-02-08 16:31:44

长大以后,我一定要买一款能看到别人电脑里照片的电脑~~~~


by Yungchit @ 2022-02-08 16:34:13

所以说我这个代码有问题吗。。。哪位大佬帮忙看下


by 我不是管理员 @ 2022-02-08 16:40:02

@Yungchit 正在为您跑对拍,请稍后……


by Yungchit @ 2022-02-08 16:42:58

@a1029 谢谢orz,大佬你觉得我这个有啥明显的错误没,虽然我这个代码风格比较nt但我觉得跑着还没啥问题_T_不知道为啥过不了


by a1029 @ 2022-02-08 16:50:29

@Yungchit 奇了怪了,和标准答案确实一模一样。找了半天找不出错


by 我不是管理员 @ 2022-02-08 16:51:29

找到一组数据:


by 我不是管理员 @ 2022-02-08 16:52:16

输入:

32
36244675679575268844756656096195

by 我不是管理员 @ 2022-02-08 16:57:31

@Yungchit


by 我不是管理员 @ 2022-02-08 16:58:12

你多了一个空行(我个人觉得不可能,但这是你的输出和标准答案的唯一区别)


上一页 | 下一页