HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)
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(字符转换~)的更多相关文章
- HDU 2140 Michael Scofield's letter
http://acm.hdu.edu.cn/showproblem.php?pid=2140 Problem Description I believe many people are the fan ...
- HDOJ(HDU) 4847 Wow! Such Doge!(doge字符统计)
Problem Description Chen, Adrian (November 7, 2013). "Doge Is An Ac- tually Good Internet Meme. ...
- HDOJ/HDU 1161 Eddy's mistakes(大写字母转换成小写字母)
Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for e ...
- HDOJ(HDU).1035 Robot Motion (DFS)
HDOJ(HDU).1035 Robot Motion [从零开始DFS(4)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DF ...
- HDOJ(HDU).1015 Safecracker (DFS)
HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1 ...
- HDU 2087 剪花布条(字符串匹配,KMP)
HDU 2087 剪花布条(字符串匹配,KMP) Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出 ...
- HDOJ(HDU).1412 {A} + {B} (STL SET)
HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include ...
- HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)
HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...
- HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)
HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和) 点我挑战题目 题意分析 根据数据范围和询问次数的规模,应该不难看出是个数据结构题目,题目比较裸.题中包括以下命令: 1.Add(i ...
随机推荐
- Codevs 1225 八数码难题
1225 八数码难题 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description Yours和zero在研究A*启发式算法.拿到一道经典的 ...
- 检查mysql数据库是否存在坏表脚本
#!/bin/bash #此脚本的主要用途是检测mysql服务器上所有的db或者单独db中的坏表 #变量说明 pass mysql账户口令 name mysql账号名称 data_path mysql ...
- APUE学习笔记-一些准备
从开始看APUE已经有快一个星期了,由于正好赶上这几天清明节放假,难得有了三天空闲假期可以不受打扰的学习APUE,现在已经看完前六章了,里面的大部分例程也都亲自编写,调试过了.但总觉得这样学过就忘,因 ...
- js禁止高频率连续点击思路
1.类似react的数据流,点击之后立即设置值为空,当返回值后才可以点击 2.设置定时器,每次进入之前先清空掉定时器,然后开启定时器 <main> <div id="me& ...
- css3怎么隐藏dom:4种方法
1.display:none; 2.position:absolute; left:-99999px; 3.visibility:hidden; 4.opacity:0;
- yii2单个视图加载jss,css
1,定义资源:首先在AppAsset.php里面定义2个方法, //按需加载css public static function addCss($view, $cssfile) { $view-> ...
- 第一个CUDA程序
开始学CUDA 先写一个简单的 #include<iostream>__global__ void add( int a, int b, int *c ) { *c = a + b;}in ...
- Computer Talker with C# z
Using the Code Add a textbox named 'txtWords' to a form. Add a button named 'btnSpeak' to a form. Ad ...
- JDBC 基础知识总结
1. 何谓JDBC --- Java Database Connectivity. 由Sun 公司提供的访问数据库的一组java类和接口,用来对数据库进行链接.发送SQL语句.处理返回结果,为开发 ...
- Penetration test
Contents 1 History 2 Standards and certification 3 Tools 3.1 Specialized OS distributions 3.2 Softwa ...