ACM (TJU) : 2966


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

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

int main ()
{
    char input [12];

    while ( gets (input) ) {

        bool pair = true;
        int length = strlen (input);

        if ( input [0] == input [1] )
            pair = false;

        if ( pair ) {

            for ( int i = 0; i < length / 2; i++ )
                printf ("%c", input [0]);

            for ( int i = 0; i < length / 2; i++ )
                printf ("%c", input [length - 1]);
        }

        else {

            for ( int i = 0; i < length; i += 2 )
                printf ("%c%c", input [0], input [length - 1]);
        }

        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