ZOJ - 3878 Convert QWERTY to Dvorak

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AcmAres/article/details/79954333

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;
}
阅读更多

没有更多推荐了,返回首页