zoukankan      html  css  js  c++  java
  • HDU 2140 Michael Scofield'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 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!
     
    代码:
    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn = 1e5 + 10;
    char s[maxn];
    char a[11]={'b', 'q', 't', 'm', 'i', 'c', 'a', 'e', 'l'};
    char b[11]={' ',  ',', '!', 'l', 'e', 'a', 'c', 'i', 'm'};
    
    
    int main() {
        while(~scanf("%s", s)) {
            int len = strlen(s);
            for(int i = 0; i < len; i ++) {
                if(s[i] == 'b')
                    s[i] = ' ';
                else if(s[i] == 't')
                    s[i] = '!';
                else if(s[i] == 'm')
                    s[i] = 'l';
                else if(s[i] == 'i')
                    s[i] = 'e';
                else if(s[i] == 'c')
                    s[i] = 'a';
                else if(s[i] == 'a')
                    s[i] = 'c';
                else if(s[i] == 'e')
                    s[i] = 'i';
                else if(s[i] == 'l')
                    s[i] = 'm';
                else if(s[i] == 'q')
                    s[i] = ',';
            }
    
            printf("%s
    ", s);
        }
        return 0;
    }
    

      

  • 相关阅读:
    2011全国大学生电子竞赛我们组的方案——A题开关电源模块并联供电系统(草稿)
    perl 引用实例
    R 批量读取本地文件
    R语言对数据集进行排序
    perl 常用函数和符号
    Linux下设置环境变量
    读取前200行
    R字符串处理
    R graph:如何自定义坐标轴刻度标示(tick label)
    perl中如何调用R语言
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/9410836.html
Copyright © 2011-2022 走看看