您的位置:首页 > 其它

zoj3878——Convert QWERTY to Dvorak

2016-04-02 18:47 447 查看
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;


我想跟出这个题的人好好谈谈!

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#define MAXN 1000000
using namespace std;
char a[MAXN+10];
char conven(char a)
{
if(a=='-')
return '[';
else if(a=='_')
return '{';
else if(a=='+')
return '}';
else if(a=='=')
return ']';
else if(a=='Q')
return '"';
else if(a=='q')
return '\'';
else if(a=='W')
return '<';
else if(a=='w')
return ',';
else if(a=='E')
return '>';
else if(a=='e')
return '.';
else if(a=='R')
return 'P';
else if(a=='r')
return 'p';
else if(a=='T')
return 'Y';
else if(a=='t')
return 'y';
else if(a=='Y')
return 'F';
else if(a=='y')
return 'f';
else if(a=='U')
return 'G';
else if(a=='u')
return 'g';
else if(a=='I')
return 'C';
else if(a=='i')
return 'c';
else if(a=='O')
return 'R';
else if(a=='o')
return 'r';
else if(a=='P')
return 'L';
else if(a=='p')
return 'l';
else if(a=='{')
return '?';
else if(a=='[')
return '/';
else if(a=='}')
return '+';
else if(a==']')
return '=';
else if(a=='S')
return 'O';
else if(a=='s')
return 'o';
else if(a=='D')
return 'E';
else if(a=='d')
return 'e';
else if(a=='F')
return 'U';
else if(a=='f')
return 'u';
else if(a=='G')
return 'I';
else if(a=='g')
return 'i';
else if(a=='H')
return 'D';
else if(a=='h')
return 'd';
else if(a=='J')
return 'H';
else if(a=='j')
return 'h';
else if(a=='K')
return 'T';
else if(a=='k')
return 't';
else if(a=='L')
return 'N';
else if(a=='l')
return 'n';
else if(a==':')
return 'S';
else if(a==';')
return 's';
else if(a=='"')
return '_';
else if(a=='\'')
return '-';
else if(a=='Z')
return ':';
else if(a=='z')
return ';';
else if(a=='X')
return 'Q';
else if(a=='x')
return 'q';
else if(a=='C')
return 'J';
else if(a=='c')
return 'j';
else if(a=='V')
return 'K';
else if(a=='v')
return 'k';
else if(a=='B')
return 'X';
else if(a=='b')
return 'x';
else if(a=='N')
return 'B';
else if(a=='n')
return 'b';
else if(a=='<')
return 'W';
else if(a==',')
return 'w';
else if(a=='>')
return 'V';
else if(a=='.')
return 'v';
else if(a=='?')
return 'Z';
else if(a=='/')
return 'z';
else
return a;
}
int main()
{

int i;
while(gets(a))
{
for(i=0;a[i]!='\0';++i)
a[i]=conven(a[i]);
for(i=0;a[i]!='\0';++i)
printf("%c",a[i]);
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: