求助第四个测试点的数据

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

ryyc @ 2022-02-17 14:56:09

#include<iostream>

using namespace std;

int main ()
{
    int n,a[101];
    cin >> n;
    char x[101];
    for ( int i = 1; i <= n; i ++ )
    {
        cin >> x[i];   
        a[i] = x[i] - '0';
    }
    for ( int i = 1; i <= 5; i ++ )
    {
        for ( int j = 1; j <= n; j ++ )
        {
            if( a[j] == 0 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "X.X";  break;
                    case 3: cout << "X.X";  break;
                    case 4: cout << "X.X";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 1 )
            {
                cout << "..X";
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 2 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "..X";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "X..";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 3 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "..X";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "..X";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 4 )
            {
                switch(i)
                {
                    case 1: cout << "X.X";  break;
                    case 2: cout << "X.X";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "..X";  break;
                    case 5: cout << "..X";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 5 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "X..";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "..X";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 6 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "X..";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "X.X";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 7 )
            {
                switch(i)
                {
                    case 1: cout << "XXX.";  break;
                    case 2: cout << "..X.";  break;
                    case 3: cout << "..X.";  break;
                    case 4: cout << "..X.";  break;
                    case 5: cout << "..X.";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 8 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "X.X";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "X.X";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
            if( a[j] == 9 )
            {
                switch(i)
                {
                    case 1: cout << "XXX";  break;
                    case 2: cout << "X.X";  break;
                    case 3: cout << "XXX";  break;
                    case 4: cout << "..X";  break;
                    case 5: cout << "XXX";  break;
                }
                if ( j != n )
                {
                    cout << "." ;
                }
            }
        }
        cout << endl;
    }

    return 0;
}

by 编码落寞 @ 2022-02-17 15:17:44

@ryyc

你的7好像多了一列


by ryyc @ 2022-02-17 15:47:33

@编码落寞 AC了,感激!


|