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(字符转换~)

时间: 2024-10-18 06:47:12

HDOJ/HDU 2140 Michael Scofield's letter(字符转换~)的相关文章

HDU 2140 Michael Scofield&#39;s letter

http://acm.hdu.edu.cn/showproblem.php?pid=2140 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 cra

HDOJ/HDU 1161 Eddy&#39;s mistakes(大写字母转换成小写字母)

Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for example "computer science" is written frequently "coMpUtEr scIeNce" by him, this mistakes lets Eddy's English teacher be extremely disco

HDOJ(HDU) 4847 Wow! Such Doge!(doge字符统计)

Problem Description Chen, Adrian (November 7, 2013). "Doge Is An Ac- tually Good Internet Meme. Wow.". Gawker. Retrieved November 22, 2013. Doge is an Internet meme that became popular in 2013. The meme typically con- sists of a picture of a Shi

HDOJ/HDU 1250 Hat&#39;s Fibonacci(大数~斐波拉契)

Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4) Your task is to take

java GBK字符转换成为UTF-8编码字符

import java.util.HashMap; import java.util.Map; /** * 创建日期: 2014-04-18 10:36:25 * 作者: 黄飞 * mail:[email protected] [email protected] * ©版权归作者所有 * */ public class ConverFromGBKToUTF8 { public static void main(String[] args) { try { ConverFromGBKToUTF8

*数组-01. 字符转换

1 /* 2 * Main.c 3 * E1-数组-01. 字符转换 4 * Created on: 2014年8月20日 5 * Author: Boomkeeper 6 ******部分通过********** 7 */ 8 9 #include <stdio.h> 10 11 int main(void) { 12 13 char str[80] = { -1 }; 14 15 gets(str); 16 17 int i; 18 for (i = 0; i < 80; i++)

发送邮件字符转换

//將html轉為text public string HtmlToText(string strContent) { strContent = strContent.Replace("&amp", "&"); strContent = strContent.Replace("''", "'"); strContent = strContent.Replace("&lt", &quo

IO-04字节-字符转换流

掌握OutputStreamWriter和InputStreamReader的作用. 在整个IO包中,实际上就是分为字节流和字符流,但除了这两个流之外,还存在一组字节-字符流转换类. OutputStreamWriter:是Writer的子类,将输出的字符流编程字节流,既:将一个字符流的输出对象变成字节流输出对象. InputStreamReader:是Reader的子类,将输入的字节流变成字符流.既:将一个字节流的输入对象变成字符流的输入对象. 字符流转换成字节流的代码: package li

1.字符转换

1.将单字节Char转化为双字节的wchar_t的转换函数 wchar_t* c2w(const char *str){     int length = strlen(str)+1;     wchar_t *t = (wchar_t*)malloc(sizeof(wchar_t)*length);     memset(t,0,length*sizeof(wchar_t));     MultiByteToWideChar(CP_ACP,0,str,strlen(str),t,length)