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;
}

POJ 之 WERTYU的更多相关文章

  1. POJ 2538 WERTYU水的问题

    [题目简述]:题意非常easy,没有trick. [分析]:事实上这题还是挺有趣的,在 算法竞赛入门经典中也有这一题. 详见代码: // 120K 0Ms /* 边学边做 -- */ // 字符串:W ...

  2. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  3. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  4. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  5. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  6. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  7. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  8. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  9. POJ 2752 Seek the Name, Seek the Fame [kmp]

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Ac ...

随机推荐

  1. DNS_主从服务_详细搭建&&配置

    DNS主从 安装环境: 三台dns服务器如下: 系统:均为centos7 dns_master:192.168.169.194 dns_slave-1:192.168.169.195 dns_slav ...

  2. 96Boards扩展板 STM32 B96B-F446VE 牛刀小试

    前言 原创文章,转载引用务必注明链接,水平有限,如有疏漏,欢迎指正. 本文使用Markdown写成,为获得更好的阅读体验和正常的链接.图片显示,请访问我的博客原文: http://www.cnblog ...

  3. Shell脚本之:case

    case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构. case语句的语法 case 值 in 模式1) command1 command2 co ...

  4. qrCode生成二维码图片

    QRCode.js 是一个用于生成二维码图片的插件. 1.文件脚本 var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,th ...

  5. ES 30 - Elasticsearch生产集群的配置建议

    目录 1 服务器的内存 2 服务器的CPU 3 服务器的磁盘 4 集群的网络 5 集群的节点个数 6 JVM的参数设置 7 集群的数据量 8 总结 在生产环境中, 要保证服务在各种极限情况下的稳定和高 ...

  6. C#高级编程八十一天----捕获异常

    捕获异常 前面主要说了关于异常的一些基础和理论知识,没有进入到正真的异常案例,这一讲通过几个案例来描写叙述一下异常的捕获和处理. 案例代码: using System; using System.Co ...

  7. WebStorm 常用功能

    WebStorm 常用功能的使用技巧分享 WebStorm 是 JetBrain 公司开发的一款 JavaScript IDE,使用非常方便,可以使编写代码过程更加流畅. 本文在这里分享一些常用功能的 ...

  8. webpack 样式分离之The root route must render a single element

    公司项目使用的是webpack1,使用extract-text-webpack-plugin 插件无法将css分离出来,检查原因,发现有如下代码 <Route path="/home& ...

  9. excel表格定义导入到powerdesigner脚本

    打开powerdesigner,shift + ctrl + X 打开脚本窗口 输入执行的脚本,点 run 即可. 简单的导入Excel脚本 '开始 Option Explicit Dim mdl ' ...

  10. 链接数据库代码封装DBDA

    <?php class DBDA { public $host = "localhost"; //服务器地址 public $uid = "root"; ...