ACM (TJU) : 2309


#include <iostream>
using namespace std;

void print ()
{
    cout << "+---+---+---+---+---+---+---+---+" << endl;
}

int main ()
{
    char white [100];
    char black [100];

    while ( gets (white) ) {

        gets (black);

        int a [8] [8] = {{0, 1, 0, 1, 0, 1, 0, 1},
        {1, 0, 1, 0, 1, 0, 1, 0},
        {0, 1, 0, 1, 0, 1, 0, 1},
        {1, 0, 1, 0, 1, 0, 1, 0},
        {0, 1, 0, 1, 0, 1, 0, 1},
        {1, 0, 1, 0, 1, 0, 1, 0},
        {0, 1, 0, 1, 0, 1, 0, 1},
        {1, 0, 1, 0, 1, 0, 1, 0}};

        char b [8] [8];

        for ( int i = 0; i < 8; i++ ) {
            for ( int j = 0; j < 8; j++ )
                b [i] [j] = 'z';
        }

        int length = strlen (white);
        for ( int i = 7; i < length; i++ ) {

            if ( white [i] > 64 && white [i] < 91 ) {
            b [8 - (white [i+2] - '0')] [white [i+1] - 'a'] = white [i];
            i += 3;
            }
            else if (white [i] > 96 && white [i] < 123)
            b [8 - (white [i+1] - '0')] [white [i] - 'a'] = 'P';
        }


        length = strlen (white);
        for ( int i = 7; i < length; i++ ) {

            if ( black [i] > 64 && black [i] < 90 ) {
            b [8 - (black [i+2] - '0')] [black [i+1] - 'a'] = (black [i] + 32);
            i += 3;
            }
            else if (black [i] > 96 && black [i] < 123)
            b [8 - (black [i+1] - '0')] [black [i] - 'a'] = 'p';
        }




        for ( int i = 0; i < 8; i++ ) {
            print ();
            cout << '|';
            for ( int j = 0; j < 8; j++ ) {
                if ( b [i] [j] != 'z' && a [i] [j] == 0)
                cout << "." << b [i] [j] << "." << "|";

                else if ( b [i] [j] != 'z' && a [i] [j] == 1)
                cout << ":" << b [i] [j] << ":" << "|";

                else if ( b [i] [j] == 'z' && a [i] [j] == 0)
                cout << "..." << "|";

                else if ( b [i] [j] == 'z' && a [i] [j] == 1)
                cout << ":::" << "|";
            }

            cout << endl;
        }

        print ();
    }
    return 0;

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s