Problem Description
I believe many people is the fans of the prison break. How clever Michael is!! In order that the message won ' t is found by FBI easily, he usually send code letters to Sara by a paper crane. Hence, the paper Crane is Michael in the heart of Sara. Now can I write a program to help Sara encode the letter from Michael easily?
The letter from Michael every time is a string of lowercase letters. You should encode letters as the rules below:
B is ", Q is", ', T is '! ", M is L, I was E, C is a, A is C, E is I, l am m. It is interesting. Is your found that it's just change Michael to Leahcim?
Input
The input would consist of several cases, one per line.
Each case was a letter from Michael, the Letteres won ' t exceed 10000.
Output
For each case, the output of the Encode letter one line.
Sample Input
Pmicsibforgevibliqbscrct
Ebmovibyout
Sample Output
Please forgive me, sara!
I love you!
is to enter a line of string, and then according to B is ' space ', Q is ', ', T is '! ', M is L, I was E, C is a, A was C, E is a, an is a, and the output converted string!
Here, I use a map to store the characters that need to be converted, and then look for the output.
Import Java. Util. HashMap;Import Java. Util. Map;Import Java. Util. Scanner;public class main{public static void Main (string[] args) {map<character, character> Map = new Hashmap< ; Character, Character> ();Map. Put(' B ',"');Map. Put(' Q ',', ');Map. Put(' t ','! ');Map. Put(' m ',' l ');Map. Put(' I ',' E ');Map. Put(' C ',' A ');Map. Put(' A ',' C ');Map. Put(' E ',' I ');Map. Put(' l ',' m ');Scanner sc = new Scanner (System. in);while (SC. Hasnext()) {String STR=SC. Next();for (int i=0; I<str.length (); i++) {if (map. Get(str. CharAt(i))! =null) {System. out. Print(Map. Get(str. CharAt(i)));}else{System. out. Print(str. CharAt(i));}} System. out. println();} }}
Hdoj/hdu 2140 Michael Scofield ' s letter (character conversion ~)