UVa 10222 - Decode the Mad man

来源:互联网 发布:java 排序算法总结 编辑:程序博客网 时间:2024/05/20 05:57

题目:解码对应的字符串。

分析:简单题。通过观察每个字母是对应键盘上的左面的第二个,大写改成小写即可。

注意:其他的字符按原来样式输出,如格式控制和数字。

#include <iostream>#include <cstdlib>#include <cstdio>using namespace std;char temp[] = "qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";char maps[256],ch;int main(){for ( int i = 0 ; i < 128 ; ++ i )maps[i] = (char)i;for ( int i = 2 ; temp[i] ; ++ i )maps[temp[i]] = temp[i-2];while ( (ch = getchar()) != EOF ) {if ( ch >= 'A' && ch <= 'Z' )ch += 'a'-'A';printf("%c",maps[ch]);}return 0;}

原创粉丝点击