ACM (TJU) : 1031


#include <stdio.h>
#include <string.h>

int main ()
{
    int s;
    char number [10];

    while ( scanf ("%d %s", &s, number) ) {
        if ( s == 0 && strcmp (number, "0") == 0 )
            return 0;

        // 1st line
        for ( int i = 0; number [i] != 0; i++ ) {
            if ( i )
                printf (" ");

            switch (number [i] - '0') {
                case 1 :
                case 4 :
                    for ( int j = 0; j < s + 2; j++ )
                        printf (" ");
                    break;
                default :
                    printf (" ");
                    for ( int j = 0; j < s; j++ )
                        printf ("-");
                    printf (" ");
            }
        }
        printf ("\n");

        // 1st vertical
        for ( int line = 0; line < s; line++ ) {
            for ( int i = 0; number [i] != 0; i++ ) {
                if ( i )
                    printf (" ");
                // left
                switch (number [i] - '0') {
                    case 1 :
                    case 2 :
                    case 3 :
                    case 7 :
                        printf (" ");
                        break;
                    default :
                        printf ("|");
                }

                // right
                switch (number [i] - '0') {
                    case 5 :
                    case 6 :
                        for ( int j = 0; j <= s; j++ )
                            printf (" ");
                        break;
                    default :
                        for ( int j = 0; j < s; j++ )
                            printf (" ");
                        printf ("|");
                }
            }

            printf ("\n");
        }


        // 2nd horizontal
        for ( int i = 0; number [i] != 0; i++ ) {
            if ( i )
                printf (" ");

            switch (number [i] - '0') {
                case 1 :
                case 7 :
                case 0 :
                    for ( int j = 0; j < s + 2; j++ )
                        printf (" ");
                    break;
                default :
                    printf (" ");
                    for ( int j = 0; j < s; j++ )
                        printf ("-");
                    printf (" ");
            }
        }
        printf ("\n");

        // 2nd vertical
        for ( int line = 0; line < s; line++ ) {
            for ( int i = 0; number [i] != 0; i++ ) {
                if ( i )
                    printf (" ");
                // left
                switch (number [i] - '0') {
                    case 1 :
                    case 3 :
                    case 4 :
                    case 5 :
                    case 7 :
                    case 9 :
                        printf (" ");
                        break;
                    default :
                        printf ("|");
                }

                // right
                switch (number [i] - '0') {
                    case 2 :
                        for ( int j = 0; j <= s; j++ )
                            printf (" ");
                        break;
                    default :
                        for ( int j = 0; j < s; j++ )
                            printf (" ");
                        printf ("|");
                }
            }

            printf ("\n");
        }

        // 3rd horizon
        for ( int i = 0; number [i] != 0; i++ ) {
            if ( i )
                printf (" ");

            switch (number [i] - '0') {
                case 1 :
                case 4 :
                case 7 :
                    for ( int j = 0; j < s + 2; j++ )
                        printf (" ");
                    break;
                default :
                    printf (" ");
                    for ( int j = 0; j < s; j++ )
                        printf ("-");
                    printf (" ");
            }
        }
        printf ("\n\n");
    }

    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