WERTYU
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8371   Accepted: 4007

Description


A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.

Input

Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.

Output

You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

Sample Input

O S, GOMR YPFSU/

Sample Output

I AM FINE TODAY.

算法分析:下面的算法,写起来实在是过于麻烦而且容易出错,现提供常量数组的做法。初始化定义一个字符数组s[]={",,,,,,,,,,,,"}
将全部的键盘输进去,输出时,先遍历一遍找到对应的字符,然后输出该字符的钱一个字符就可以了,此写法不容易出错!
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; char s[1000000]; int main()
{
char t[10000];
int i, j;
int len;
//定义区
s['1']='~'; s['2']='1'; s['3']='2'; s['4']='3'; s['5']='4'; s['6']='5'; s['7']='6'; s['8']='7';
s['9']='8'; s['0']='9'; s['-']='0'; s['=']='-';
s['W']='Q'; s['E']='W'; s['R']='E'; s['T']='R'; s['Y']='T'; s['U']='Y';
s['I']='U'; s['O']='I'; s['P']='O'; s['[']='P'; s[']']='[';
s['\\']=']';
s['\'']=';';
s['S']='A'; s['D']='S'; s['F']='D'; s['G']='F'; s['H']='G'; s['J']='H'; s['K']='J'; s['L']='K'; s[';']='L'; s['X']='Z'; s['C']='X'; s['V']='C'; s['B']='V'; s['N']='B'; s['M']='N'; s[',']='M'; s['.']=','; s['/']='.'; while(gets(t)!=NULL)
{
len = strlen(t);
for(i=0; i<len; i++)
{
if(t[i]==' ')
{
printf(" ");
}
else
{
printf("%c", s[t[i]] );
}
}
printf("\n");
}
return 0;
}

最新文章

  1. [C#]浅析ref、out参数
  2. SOA的浅析
  3. win7(X64)系统下cuda7.5和VS2013的配置
  4. 洛谷U5653 宋荣子的小饼干
  5. JS监听关闭浏览器事件
  6. 关于SVN 目录结构,使用教程
  7. asp 文件上传(ASPUpload组件上传)
  8. hunnu 11313 无重复元素序列的最长公共子序列转化成最长递增子序列 求法及证明
  9. 网关协议学习:CGI、FastCGI、WSGI、uWSGI
  10. Ajax得知(两)—— 一个简单的Ajax示例
  11. Python 一些有趣的技巧哦!
  12. 如何高效的编写Verilog HDL——进阶版
  13. Java Web项目部署Tomcat运行出错
  14. 采用JSP+JavaBean的方式进行简单的实现用户的网页登陆实例
  15. XMPP系列(五)---文件传输
  16. promise原理
  17. C-switch case之如何巧妙判断范围区域
  18. Leetcode 11.盛最多水的容器 By Python
  19. BZOJ 2159: Crash 的文明世界(树形dp+第二类斯特林数+组合数)
  20. 题解—— 洛谷 p1993 小K的农场(差分约束&amp;负环判断)

热门文章

  1. Oracle数据泵远程导入文件到本地数据库
  2. 微信小程序 - 考试前三排名实现
  3. #測试相关#Getting “junit.framework.AssertionFailedError: Forked Java VM exited abnormally” Exception
  4. VueJS样式绑定v-bind:class
  5. 基于mysql本身的主从复制
  6. warning: mysql-community-libs-5.7.11-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5
  7. KVM+VNC 虚拟机远程管理
  8. Appium python Uiautomator2 多进程问题
  9. Docker入门系列8
  10. 在VMware下安装CentOS系列1:配置VMware