Hdoj/hdu 2140 Michael Scofield ' s letter (character conversion ~)

Source: Internet
Author: User

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&lt ; 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 ~)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.