ACM学习历程—ZOJ3878 Convert QWERTY to Dvorak(Hash && 模拟)
Description
Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a broken Caps Lock key, so Edward never presses the broken Caps Lock key. Luckily, all the other keys on the QWERTY keyboard work well. Every day, he has a lot of documents to type. Thus he needs a converter to translate QWERTY into Dvorak. Can you help him?
The QWERTY Layout and the Dvorak Layout are in the following:

The QWERTY Layout

The Dvorak Layout
Input
A QWERTY document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.
Output
The Dvorak document.
Sample Input
Jgw Gqm Andpw a H.soav Patsfk f;doe
Nfk Gq.d slpt a X,dokt vdtnsaohe
Kjd yspps,glu pgld; aod yso kd;kgluZ
1234567890
`~!@#$%^&*()}"']_+-=ZQqWEwe{[\|
ANIHDYf.,bt/
ABCDEFuvwxyz
Sample Output
Hi, I'm Abel, a Dvorak Layout user.
But I've only a Qwerty keyboard.
The following lines are for testing:
1234567890
`~!@#$%^&*()+_-={}[]:"'<>,.?/\|
ABCDEFuvwxyz
AXJE>Ugk,qf;
这个题直接暴力手打了两张表,然后用map进行了映射。
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string> using namespace std; char from[100] =
{
'~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
'`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '|',
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\',
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"',
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'',
'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?',
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', ' '
};
char to[100] =
{
'~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '{', '}',
'`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '[', ']',
'"', '<', '>', 'P', 'Y', 'F', 'G', 'C', 'R', 'L', '?', '+', '|',
'\'',',', '.', 'p', 'y', 'f', 'g', 'c', 'r', 'l', '/', '=', '\\',
'A', 'O', 'E', 'U', 'I', 'D', 'H', 'T', 'N', 'S', '_',
'a', 'o', 'e', 'u', 'i', 'd', 'h', 't', 'n', 's', '-',
':', 'Q', 'J', 'K', 'X', 'B', 'M', 'W', 'V', 'Z',
';', 'q', 'j', 'k', 'x', 'b', 'm', 'w', 'v', 'z', ' '
}; char str; int main()
{
//freopen("test.in", "r", stdin);
map<char, char> Hash;
for (int i = 0; i < 100; ++i)
Hash[from[i]] = to[i];
while ((str = getchar()) != EOF)
{
if(str == '\n')
printf("\n");
else
printf("%c", Hash[str]);
}
return 0;
}
ACM学习历程—ZOJ3878 Convert QWERTY to Dvorak(Hash && 模拟)的更多相关文章
- ACM学习历程——UVA 127 "Accordian" Patience(栈;模拟)
Description ``Accordian'' Patience You are to simulate the playing of games of ``Accordian'' patie ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
- 模拟 ZOJ 3878 Convert QWERTY to Dvorak
题目传送门 /* 模拟:手敲map一一映射,累! 除了忘记读入字符串不能用gets用getline外还是很顺利的AC了:) */ #include <cstdio> #include &l ...
- zoj 3878 Convert QWERTY to Dvorak【好坑的模拟】
Convert QWERTY to Dvorak Time Limit: 2 Seconds Memory Limit: 65536 KB Edward, a poor copy typis ...
- (字符串 键盘转换)Convert QWERTY to Dvorak -- zoj -- 5526
链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5526 Time Limit: 2 Seconds Memor ...
- Convert QWERTY to Dvorak
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- 完成了C++作业,本博客现在开始全面记录acm学习历程,真正的acm之路,现在开始
以下以目前遇到题目开始记录,按发布时间排序 ACM之递推递归 ACM之数学题 拓扑排序 ACM之最短路径做题笔记与记录 STL学习笔记不(定期更新) 八皇后问题解题报告
- ACM学习历程—HDU 5512 Pagodas(数学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5512 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是给了初始的集合{a, b},然后取集合里 ...
- ACM学习历程—HDU5521 Meeting(图论)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5521 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是一个人从1开始走,一个人从n开始走.让最 ...
随机推荐
- ExtJs4学习(二):Dom操作
如今主流的JS框架要数ExtJs和JQuery应用的比較广泛.JQuery属于轻量级的,一般做站点应用比較常见.可见块头小的优势. ExtJs比較庞大,它除了对主要的JS语法和HTML DOM操作方式 ...
- 在VMware下安装CentOS系列1:配置VMware
安装环境 VMware Workstation v9.0.0 build-812388 CentOS-6.3-x86_64-minimal.iso minimal,bin-DVD,netinstall ...
- andeoid硬件解码
Finally, I must say, finally, we get low-level media APIs in Android, the Android hardware decoding ...
- java 发展简史
[0]README 0.1) 本文转自 core java volume 1,仅供了解Java 的发展历史,它的前世今生,所谓知己知彼,百战不殆(just a joke) : [1]java 发展简史 ...
- Executors几种常用的线程池性能比较
java编程中,经常会利用Executors的newXXXThreasPool生成各种线程池,今天写了一小段代码,简单测试了下三种常用的线程池: import com.google.common.ut ...
- ios-逆向 手把手安装最新版Theos
Theos.最初由DHowett进行开发,由于DHwoett去了微软,不再有时间维护了,所以Adam Demasi(kirb)接手了他的工作,并且添加了很多全新的功能.所以,之前书上<iOS ...
- MySQL 创建自定义函数(2)
说明:下面创建一个函数,调用自定义函数返回一个返回一个随机数. (1) 创建自定义函数
- mongodb 配置单实例与双实例
环境: centos6.5 192.168.16.70 配置单实例mongodb:[root@www soft]# tar xf mongodb-linux-x86_64-rhel62-3.2.7.t ...
- IIS7:通过脚本来配置ftp站点
Appcmd.exe是IIS7提供的一个管理站点的命令行工具,同时支持Ftp和Http的站点,功能还算强大,具体使用方法参考微软网站. 需求 我这里的例子主要配置一个Ftp站点,并且允许CcUser这 ...
- python cookbook第三版学习笔记九:函数
接受任意数量参数的函数. 当传入函数的参数个数很多的时候,在函数定义的时候不需要为每一个参数定义一个变量,可以用*rest的方式来包含多余的参数. 如下面的代码,*rest包含了2,3,4这3个参数. ...