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 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. You are to replace each letter or punction 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.

思路:先将键盘上的键位存储于字符串中,如果匹配的话就输出前一位,空格和换行照样输出;

#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main()
{ //先将其存放在字符串中,如果匹配输出前一位
string s="`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./";
char c;
while((c=getchar())!=EOF)
{
if(c==' '||c=='\n') //如果有空格和换行,照样输出
cout<<c;
else
{ for(int i=1;i<s.length();i++)
{
if(c==s[i]) //依次寻找匹配
cout<<s[i-1];
}
}
}
return 0;
}

最新文章

  1. Linux上搭建Hadoop2.6.3集群以及WIN7通过Eclipse开发MapReduce的demo
  2. sudo: no tty present and no askpass program specified(转)
  3. 【GoLang】GoLang 中 make 与 new的区别
  4. Mac OS—苹果搭建Android开发环境
  5. DataGrid Column Group (合并表头)
  6. Top 7 Myths about HTTPS
  7. linux相关解压命令
  8. rabbitmq pika connection closed
  9. TTTAttributedLabel使用介绍(转)
  10. SDP (Session Description Protocol)
  11. 团队作业8——第二次项目冲刺(Beta阶段)--5.24 forth day
  12. bootstrap浅谈
  13. jquery 防止当前页面被Iframe嵌套,防止登录页面Iframe被嵌套
  14. Collision (hdu-5114
  15. linux学习笔记1——指令的基本格式及基本文件操作
  16. WebService入门Demo
  17. 《C++ Primer Plus》16.1 string类 学习笔记
  18. SpringInAction--Bean参数的自动注入
  19. jquery echarts 饼状图
  20. linux命令(21):more命令

热门文章

  1. 自己对WEBGL坐标系的转换过程的理解【如图】
  2. [luogu P2590 ZJOI2008] 树的统计 (树链剖分)
  3. [Libre 6282] 数列分块入门 6 (分块)
  4. 2019-03-28 SQL Server select 1
  5. 关于安卓sdk开发环境的的更新-Android SDK下载和更新失败
  6. ZOJ 2315 New Year Bonus Grant
  7. pycaffe 配置
  8. oracle 解除锁表sql
  9. Java进化? Kotlin初探与集成Android项目
  10. JPEG压缩图像超分辨率重建算法