ACM (TJU) : 2946


// http://acm.tju.edu.cn/toj/showp2946.html

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

int main ()
{
    char a [18];

    gets (a);

    int length = strlen (a);

    // 1st line
    printf ("..#..");
    for ( int i = 2; i <= length; i++ ) {
        char ch = '#';

        if ( i % 3 == 0 )
            ch = '*';

        printf (".%c..", ch);
    }
    printf ("\n");

    // 2nd line
    printf (".#.#.");
    for ( int i = 2; i <= length; i++ ) {
        char ch = '#';

        if ( i % 3 == 0 )
            ch = '*';

        printf ("%c.%c.", ch, ch);
    }
    printf ("\n");

    // 3rd line
    printf ("#.%c.#", a [0]);
    for ( int i = 2; i <= length; i++ ) {
        char ch = '#';

        if ( (i + 1 <= length && (i + 1) % 3 == 0) || i % 3 == 0 )
            ch = '*';

        printf (".%c.%c", a [i - 1], ch);
    }
    printf ("\n");

    // 4th (2nd) line
    printf (".#.#.");
    for ( int i = 2; i <= length; i++ ) {
        char ch = '#';

        if ( i % 3 == 0 )
            ch = '*';

        printf ("%c.%c.", ch, ch);
    }
    printf ("\n");

    // 5th (1st) line
    printf ("..#..");
    for ( int i = 2; i <= length; i++ ) {
        char ch = '#';

        if ( i % 3 == 0 )
            ch = '*';

        printf (".%c..", ch);
    }
    printf ("\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