ACM学习历程—ZOJ3878 Convert QWERTY to Dvorak(Hash && 模拟)
2024-10-21 06:24:41
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;
}
最新文章
- 了解了下spring boot,说一下看法
- 学习Coding-iOS开源项目日志(五)
- URL优化之IIS7如何开启伪静态
- ytu 1059: 判别该年份是否闰年(水题,宏定义)
- 黄聪:WebBrowser执行和安装jQuery脚本(IEBrowse)
- 炼数成金hadoop视频干货05
- 安装ADT
- masonry结合json 制作无限滚动的瀑布流
- Bootstrap Alert 使用
- 初识Ubuntu
- 【原创】源码角度分析Android的消息机制系列(三)——ThreadLocal的工作原理
- VR虚拟现实技术在教育领域的前景展望
- BZOJ1565 植物大战僵尸 题解
- Linux集群时间同步方法
- Windows系统封装教程
- vue+cordova构建跨平台应用集成并使用Cordova plugin
- [转] Understanding-LSTMs 理解LSTM
- Chrome禁止http自动转为https
- [adminitrative][archlinux][setfont] 设置console的字体大小
- Received empty response from Zabbix Agent at [172.16.1.7]...