10222 - Decode the Mad man

 

The Problem

Once in BUET, an old professor had gone completely mad. He started talking with some peculiar words. 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 was a registered author at UVA ACM Chapter and hold a good rank on 24 hour-Online Judge) created a program that was able to decode that professor’s speech. After his invention, everyone got comfort again 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 a IBM computer equipped with a voice recognition software and students are taking their lecture from the computer screen, don’t get thundered! Because now your job is to write the same program which can decode that mad teacher's speech!

The Input

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

The test case consists of one or more words.

The 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 standard keyboard.

 问题
很久以前,在波兰的BUET大学有一个老教授完全发疯了。他开始用很特殊的文字来说话。没有人可以听得懂他的演讲及授课。最后,BUET终于陷入了难题。再也没有方法可以让他继续在大学里工作了。突然有一个学生(当然是UVA ACM学会注册的作者,并在24小时线上裁判系统上有很好的排名) 创造了一个可以将教授的话解码的程式。在此之后,这个老教授开始一如往常般地工作,每个人也都松了一口气。

因此,如果你有机会去到BUET,看到一个老师透过一个接到装有语音辨识的IBM电脑的麦克风说话,而学生则从电脑萤幕上听课,你可别吓到!因为现在你的工就是要写一个一样可以解码这个疯教授语言的程式。

输入
输入档仅含一笔测试资料,也就是编码后的讯息。

这笔测试资料含有一个或多个单字。

输出
就所给的测试资料,将解码后的单字印在一行。还好,这工作并不难,只要把每个字母或符号以键盘上在它左边第二个键的符号来取代就行了。

Sample Input

k[r dyt I[o

Sample Output

how are you
解题思路:一个一个对应输入,每个字符对应的是在键盘上左边的第二个键,如k对应h,
#include<stdio.h>
int main()
{char a;
while((a=getchar())!=EOF){
                          if(a=='\\')printf("[");
                          else if(a==']')printf("p");
                          else if(a=='[')printf("o");
                          else if(a=='P'||a=='p')printf("i");
                          else if(a=='O'||a=='o')printf("u");
                          else if(a=='I'||a=='i')printf("y");
                          else if(a=='U'||a=='u')printf("t");
                          else if(a=='Y'||a=='y')printf("r");
                          else if(a=='T'||a=='t')printf("e");
                          else if(a=='R'||a=='r')printf("w");
                          else if(a=='E'||a=='e')printf("q");
                          else if(a=='\'')printf("l");
                          else if(a==';')printf("k");
                          else if(a=='L'||a=='l')printf("j");
                          else if(a=='K'||a=='k')printf("h");
                          else if(a=='J'||a=='j')printf("g");
                          else if(a=='H'||a=='h')printf("f");
                          else if(a=='G'||a=='g')printf("d");
                          else if(a=='F'||a=='f')printf("s");
                          else if(a=='D'||a=='d')printf("a");
                          else if(a=='S'||a=='s')printf("\\");
                          else if(a=='/')printf(",");
                          else if(a=='.')printf("m");
                          else if(a==',')printf("n");
                          else if(a=='M'||a=='m')printf("b");
                          else if(a=='N'||a=='n')printf("v");
                          else if(a=='B'||a=='b')printf("c");
                          else if(a=='V'||a=='v')printf("x");
                          else if(a=='C'||a=='c')printf("z");
                          else if(a=='X'||a=='x')printf("'");
                          else if(a=='A'||a=='a')printf("]");
                          else if(a=='Z'||a=='z')printf(";");
                          else printf("%c",a);
                          }
return 0;
}


 

posted on 2013-02-05 15:34  喂喂还债啦  阅读(912)  评论(0编辑  收藏  举报