UVa 865

From Algorithmist
Jump to navigation Jump to search

865 - Substitution Cypher[edit]

Summary[edit]

Given a string which provides plaintext characters and another string which provides substitution characters, apply these substitutions to several lines of text.

Explanation[edit]

For each character in the several lines of text, check if the character is in the plaintext string. If it is, replace the character with the corresponding substitution character; otherwise, keep the original character.

Gotchas[edit]

It turns out that the term "plaintext letters" means any printable character, such as '.', '%', or even ' ' (a blank space). This means that when reading the first two strings (called plaintext letters and substitution letters), you should use a function which can read an entire line. In C/C++, you can use gets, fgets or getline.


Input[edit]

1

abc,-= y89
1234567890
This is a test.,-=

Output[edit]

1234567890
abc,-= y89
This7is717test.456