ZOJ - 3878 Convert QWERTY to Dvorak

原创 2018年04月15日 22:21:59

Convert QWERTY to Dvorak

Problem 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:

Qwerty Layout
The QWERTY Layout
Dvorak 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;

题解代码

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
char a[10000010];
char s[10000010];
int main(){
    a['q']='\'';
    a['Q']='\"';
    a['W']='<';
    a['w']=',';
    a['E']='>';
    a['e']='.';
    a['R']='P';
    a['r']='p';
    a['T']='Y';
    a['t']='y';
    a['Y']='F';
    a['y']='f';
    a['U']='G';
    a['u']='g';
    a['I']='C';
    a['i']='c';
    a['O']='R';
    a['o']='r';
    a['P']='L';
    a['p']='l';
    a['{']='?';
    a['[']='/';
    a['}']='+';
    a[']']='=';
    a['|']='|';
    a['\\']='\\';
    a['A']='A';
    a['a']='a';
    a['S']='O';
    a['s']='o';
    a['D']='E';
    a['d']='e';
    a['F']='U';
    a['f']='u';
    a['G']='I';
    a['g']='i';
    a['H']='D';
    a['h']='d';
    a['J']='H';
    a['j']='h';
    a['K']='T';
    a['k']='t';
    a['L']='N';
    a['l']='n';
    a[':']='S';
    a[';']='s';
    a['"']='_';
    a['\'']='-';
    a['Z']=':';
    a['z']=';';
    a['X']='Q';
    a['x']='q';
    a['C']='J';
    a['c']='j';
    a['V']='K';
    a['v']='k';
    a['B']='X';
    a['b']='x';
    a['N']='B';
    a['n']='b';
    a['M']='M';
    a['m']='m';
    a['<']='W';
    a[',']='w';
    a['>']='V';
    a['.']='v';
    a['?']='Z';
    a['/']='z';
    a[' ']=' ';
    a['~']='~';
    a['`']='`';
    a['!']='!';
    a['1']='1';
    a['@']='@';
    a['2']='2';
    a['#']='#';
    a['3']='3';
    a['$']='$';
    a['4']='4';
    a['5']='5';
    a['6']='6';
    a['7']='7';
    a['8']='8';
    a['9']='9';
    a['0']='0';
    a['%']='%';
    a['^']='^';
    a['&']='&';
    a['*']='*';
    a['(']='(';
    a[')']=')';
    a['_']='{';
    a['-']='[';
    a['+']='}';
    a['=']=']';
    char c;
    while (gets(s)){
        int len = strlen(s);
        for (int i = 0; i < len; ++i) {
            int x =s[i];
            cout<<a[x];
        }
        cout<<endl;
        memset(s,0, sizeof(s));
    }
    return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AcmAres/article/details/79954333

ZOJ 3878 Convert QWERTY to Dvorak(浙江省赛2015)

Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard wi...
  • caojiangxia
  • caojiangxia
  • 2015-05-10 21:30:09
  • 356

zoj3878Convert QWERTY to Dvorak(打表)

Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard wi...
  • z8110
  • z8110
  • 2015-08-21 19:26:30
  • 555

ZOJ 3878 Convert QWERTY to Dvorak

Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, a poor c...
  • yao1373446012
  • yao1373446012
  • 2016-03-20 12:22:52
  • 179

Convert QWERTY to Dvorak ZOJ 3878

Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard wi...
  • yuzhiwei1995
  • yuzhiwei1995
  • 2015-08-21 20:13:20
  • 304

zoj 3878 Convert QWERTY to Dvorak

Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, a poor c...
  • chenzhenyu123456
  • chenzhenyu123456
  • 2015-04-26 10:59:12
  • 458

ZOJ 3878 Convert QWERTY to Dvorak

Convert QWERTY to Dvorak Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %l...
  • Inite
  • Inite
  • 2016-04-20 13:11:26
  • 212

【ZOJ】[3878]Convert QWERTY to Dvorak

挺有趣 但写的时候感觉到很变态的题目思路就是建立两个字符数组保存对应的密码表 这样每一个字符只需要查找在其中一个表的位置 其对应的密码就是另一个表中对应位置的字符需要注意的是如双引号单引号这种保...
  • u011493189
  • u011493189
  • 2016-03-23 21:52:27
  • 203

ZOJ 3878 Convert QWERTY to Dvorak

题意:有一个键盘,CapLock键坏了,并且有些按键的位置装错了。已知正确的键盘与现在的键盘的按键的位置,求如果要输出正确的结果需要用怎么样的顺序按这个错位的键盘。输出这个按键的顺序 链接:http...
  • luminous11
  • luminous11
  • 2015-05-11 19:53:22
  • 255

Convert QWERTY to Dvorak ZOJ - 3878

问一个数字 转换成英文后,一共有多少个字母 比如 342 (three hundred and forty-two)有 23 个字母 代码里直接打了个表,就是data[]那个表,其实也可以去掉这个...
  • lee_haoze
  • lee_haoze
  • 2017-04-16 20:18:35
  • 93

ZOJ 3878 Convert QWERTY to Dvorak(暴力)

Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, a poor copy t...
  • MIKASA3
  • MIKASA3
  • 2016-04-03 09:39:03
  • 369
收藏助手
不良信息举报
您举报文章:ZOJ - 3878 Convert QWERTY to Dvorak
举报原因:
原因补充:

(最多只允许输入30个字)