ACM (UVa) : 445


// http://online-judge.uva.es/p/v4/445.html

#include <stdio.h>

int main ()
{
    char a [150];

    while ( gets (a) ) {

        int i = 0;
        while ( a [i] != 0 ) {
            int frq = 0;

            while ( a [i] >= '0' && a [i] <= '9' )
                frq += (a [i++] - '0');

            for ( int j = 0; j < frq; j++ ) {
                if ( a [i] == 'b' )
                    printf (" ");
                else
                    printf ("%c", a [i]);
            }

            if ( a [i] == '!' )
                printf ("\n");

            i++;
        }

        printf ("\n");
    }

    return 0;
}

One thought on “ACM (UVa) : 445

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