HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
来源:互联网 发布:云财经大数据 编辑:程序博客网 时间:2024/06/16 14:25
Problem Description
I believe many people are the fans of prison break. How clever Michael is!! In order that the message won’t be 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 you 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 is e, c is a, a is c, e is i, l is m. It is interesting. Are you found that it is just change michael to leahcim?
Input
The input will consist of several cases, one per line.
Each case is a letter from Michael, the letteres won’t exceed 10000.
Output
For each case, output the encode letter one line.
Sample Input
pmicsibforgevibliqbscrct
ebmovibyout
Sample Output
please forgive me, sara!
i love you!
就是输入一行字符串,然后根据b is ‘空格’, q is ‘,’, t is ‘!’, m is l, i is e, c is a, a is c, e is i, l is m.来转换,输出转换之后的字符串!
在这里,我用Map来存储需要转换的字符,然后查找输出。
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(字符转换~)
- hdoj 2140 Michael Scofield's letter
- HDU 2140 Michael Scofield's letter
- HDU-2140 Michael Scofield's letter 水题
- HDU#2140: Michael Scofield's letter
- Michael Scofield's letter
- HDU—— 2140 Michael Scofield's letter
- Michael Scofield's letter 2140 (字符串)
- HDOJ2140 Michael Scofield's letter
- HDOJ(HDU) 1860 统计字符
- HDOJ/HDU 1161 Eddy's mistakes(大写字母转换成小写字母)
- HDOJ 1161 Eddy's mistakes (大小写转换)
- HDU/HDOJ 3833 YY's new problem
- HDU/HDOJ----4300 Clairewd’s message
- Luc Berson's letter
- hdu 2716 字符的转换
- 英语练习78 Michael's Dream
- Michael Nielsen 's 神经网络学习之一
- 断点续传android版本
- Error inflating class android.support.design.widget.TabLayout
- python—threading.Timer【threading模块介绍03】
- 大数据学习笔记·城市计算(4)
- Linux screen命令
- HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
- (loadrunner 二)win10环境下录制脚本问题解决方案
- Python 线程和进程
- Java中使用Jedis操作Redis
- Maven常用的构建命令
- vimrc
- 黑马程序员——Java基础---面向对象(构造方法和static关键字)
- LDA-math-认识Beta/Dirichlet分布
- 使用国内镜像安装composer 在Linux--centos7上面