ACM (TJU) : 1211


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

#include <cstdio>
#include <map>
using namespace std;

int main ()
{
    char plain [70];
    char substitution [70];
    char input [70];

    gets (plain);
    gets (substitution);

    map <char, char> m;

    for ( int i = 0; plain [i] != 0; i++ )
        m [plain [i]] = substitution [i];

    printf ("%s\n", substitution);
    printf ("%s\n", plain);

    while ( gets (input) ) {
        for ( int i = 0; input [i] != 0; i++ ) {
            if ( m [input [i]] )
                printf ("%c", m [input [i]]);
            else
                printf ("%c", input [i]);
        }

        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