B - Decode the Mad man (思维)

Once in BUET, an old professor had gone completely mad. He started talking with some peculiarwords. Nobody could realize his speech and lectures. Finally the BUET authority fall in great trouble.There was no way left to keep that man working in university. Suddenly a student (definitely he wasa registered author at UVA ACM Chapter and hold a good rank on 24 hour-Online Judge) createda program that was able to decode that professor’s speech. After his invention, everyone got comfortagain and that old teacher started his everyday works as before.

  So, if you ever visit BUET and see a teacher talking with a microphone, which is connected to aIBM computer equipped with a voice recognition software and students are taking their lecture fromthe computer screen, don’t get thundered! Because now your job is to write the same program whichcan decode that mad teacher’s speech!

Input

The input file will contain only one test case i.e. the encoded message.

  The test case consists of one or more words.

Output

For the given test case, print a line containing the decoded words. However, it is not so hard task toreplace each letter or punctuation symbol by the two immediately to its left alphabet on your standardkeyboard.

Sample Input

k[r dyt I[o

Sample Output

how are you


题解:键盘上的字母错打了2位,找前两位。坑点就是从第一行到第三行是连续的,我去!!!,还有QW是本身。

#include<iostream>
#include<map>
#include<cstring>
#include<stdio.h>
using namespace std;
map<char,char>mp;
int main()
{
    char code[100]="qwertyuiop[]asdfghjkl;'zxcvbnm,.";

    for(int i=2;i<32;i++)
        mp[code[i]]=mp[code[i]-32]=code[i-2];
    char s[1000];
    gets(s);
    for(int i=0;i<strlen(s);i++)
    {
        if(mp[s[i]])
            cout<<mp[s[i]];
        else
            cout<<s[i];
    }
    cout<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值