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. Injection of resource dependencies failed解决办法总结

    今天调试项目代码,出现的引resource的报错,查原因查了好长时间才找到,现在这里总结一下,以免以后忘掉以及给大家参考. 报错大致内容入下: org.springframework.beans.fa ...

  2. 发送Post的请求代码

    通过浏览器访问的URL请求,都是GET请求,接下来代码是模拟POST发送请求 import java.io.BufferedReader; import java.io.FileNotFoundExc ...

  3. jquery:选择器 过滤器

    容易理解错误的地方: 1.假如我们想要让一个表格中第八列的所有单元格,都隐藏起来.我们可能会这么写$("table tr td:eq(8)").css("display& ...

  4. websocket使用ssl 证书,开启加密服务

    参考文章:https://fzambia.gitbooks.io/centrifugal/content/deploy/certificates.html TLS certificates TLS/S ...

  5. jenkins构建一个go项目

    Jenkins安装   最低配置: 不少于256M内存,不低于1G磁盘,jdk版本>=8 安装jdk1.8 yum install -y java-1.8.0-openjdk wget -O / ...

  6. Linux内存段的分析

        Linux 应用程序的内存分配中,是用 segment(段)进行区别的,使用 size 命令进行查看: size a.out text data bss dec hex filename a. ...

  7. ETL拉链算法汇总大全

    拉链算法总结大全: 一.0610算法(追加) 1.删除仓库表的载入日期是本次载入日期的数据,以支持重跑 delete from xxx where start_dt >=$tx_date; 2. ...

  8. 六种基本DCDC变换器拓扑结构

    1.SEPIC电路 2.

  9. MagicalRecord使用教程【转载】

    原文地址:http://www.ithao123.cn/content-96403.html 下面是在xcode5.1下ARC环境中的使用教程 1. 将 MagicalRecord 文件夹拖入到工程文 ...

  10. ssh port forwarding

    SSH端口转发,总是忘记,今天记录下.端口转发有两种,一个是local一个是remote(可能还有一种dynamic,还没有研究) 贴个链接 https://www.ssh.com/ssh/tunne ...