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. spark-submit提交方式测试Demo

    写一个小小的Demo测试一下Spark提交程序的流程 Maven的pom文件 <properties> <maven.compiler.source>1.7</maven ...

  2. 出自 HTML4 规范的可用颜色字符串值列表(常用颜色名称及对应的十六进制值)

    据称由于 HTML5 没有修改专属的颜色,HTML4 的颜色都可以在 HTML5 中正确显示. 出自 HTML4 规范的可用颜色字符串值列表如下,此表来源是 http://www.lovean.com ...

  3. 未经处理的异常在 System.Data.dll 中发生。其它信息:在应使用条件的上下文(在 &#39;***&#39; 附近)中指定了非布尔类型的表达式。

    机房收费系统中,有些人在联合查询这个模块用的是存储过程.我先尝试着在数据库中建立了一个视图.然后在UI层做个推断并生成查询条件strCondition. 在机房收费系统的"联合查询" ...

  4. vue 组件创建与销毁

    vue 组件(如对话框组件)实时创建与销毁: 使用v-if <search-history :show="showSearchHistory" @close="sh ...

  5. Vue 渲染优先级

    当 v-if 与 v-for 一起使用时,v-for 具有比 v-if 更高的优先级.

  6. android位置布局

    fill_parent 设置一个构件的布局为fill_parent将强制性地使构件扩展,以填充布局单元内尽可能多的空间.这跟Windows控件的dockstyle属性大体一致.设置一个顶部布局或控件为 ...

  7. 封装CLLocationManager定位获取经纬度

    创建调用方法,在.h文件里 #import <Foundation/Foundation.h> @interface RMMapLocation : NSObject { void (^s ...

  8. centOS 7中上网以及网卡的一些设置

    在VMWare中安装LinuxOS是个非经常见的事情. 可是,关于虚拟机的上网问题.想在这里总结一下,里面还有不懂的问题.希望能够得到前辈的解惑. 一.VMWare网卡的设置的三种选项: Bridge ...

  9. spark之pycharm开发设置

    方法一: __author__ = 'similarface' import os import sys os.environ['SPARK_HOME']="/Users/similarfa ...

  10. 巧用Excel提高工作效率

    程序员如何巧用Excel提高工作效率 主要讲解下Excel中VLOOKUP函数的使用,相比于上一篇中的内容,个人觉得这个相对高级一些. 1.使用背景 为什么会使用到这个函数呢,背景是这样的,有两个系统 ...