您的位置:首页 > 其它

ZOJ - 3878 Convert QWERTY to Dvorak (暴力)水&坑

2016-05-01 16:04 423 查看
ZOJ - 3878
Convert QWERTY to Dvorak

Time Limit:                                                        2000MS                        Memory Limit: 65536KB 64bit IO Format:                            %lld & %llu                       
SubmitStatus

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
<h4< body="">

Input

A QWERTY document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.

<h4< body="">

Output

The Dvorak document.

<h4< body="">

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

<h4< body="">

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;


Hint

Source
The 12th Zhejiang Provincial Collegiate Programming Contest
//题意:
小明的键盘和我们正常的键盘不同,如上图对应的情况,现在说输入一个字符串,让你输出小明的键盘输出的字符串。
//思路:
水题,直接模拟,但是很坑,题中要求的是输入不超过100K(1K=1024个字符),这块没看清,以为是100个字符,所以就WA了一遍。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
char s[10000010];
char c[10000010];
int main()
{
while(gets(s)!=NULL)
{
memset(c,'\0',sizeof(c));
int len=strlen(s);
for(int i=0;i<len;i++)
{
if(s[i]=='_') c[i]='{';
else if(s[i]=='-') c[i]='[';
else if(s[i]=='+') c[i]='}';
else if(s[i]=='=') c[i]=']';
else if(s[i]=='Q') c[i]='"';
else if(s[i]=='q') c[i]=39;
else if(s[i]=='W') c[i]='<';
else if(s[i]=='w') c[i]=',';
else if(s[i]=='E') c[i]='>';
else if(s[i]=='e') c[i]='.';
else if(s[i]=='R') c[i]='P';
else if(s[i]=='r') c[i]='p';
else if(s[i]=='T') c[i]='Y';
else if(s[i]=='t') c[i]='y';
else if(s[i]=='Y') c[i]='F';
else if(s[i]=='y') c[i]='f';
else if(s[i]=='U') c[i]='G';
else if(s[i]=='u') c[i]='g';
else if(s[i]=='I') c[i]='C';
else if(s[i]=='i') c[i]='c';
else if(s[i]=='O') c[i]='R';
else if(s[i]=='o') c[i]='r';
else if(s[i]=='P') c[i]='L';
else if(s[i]=='p') c[i]='l';
else if(s[i]=='{') c[i]='?';
else if(s[i]=='[') c[i]='/';
else if(s[i]=='}') c[i]='+';
else if(s[i]==']') c[i]='=';
else if(s[i]=='S') c[i]='O';
else if(s[i]=='s') c[i]='o';
else if(s[i]=='D') c[i]='E';
else if(s[i]=='d') c[i]='e';
else if(s[i]=='F') c[i]='U';
else if(s[i]=='f') c[i]='u';
else if(s[i]=='G') c[i]='I';
else if(s[i]=='g') c[i]='i';
else if(s[i]=='H') c[i]='D';
else if(s[i]=='h') c[i]='d';
else if(s[i]=='J') c[i]='H';
else if(s[i]=='j') c[i]='h';
else if(s[i]=='K') c[i]='T';
else if(s[i]=='k') c[i]='t';
else if(s[i]=='L') c[i]='N';
else if(s[i]=='l') c[i]='n';
else if(s[i]==':') c[i]='S';
else if(s[i]==';') c[i]='s';
else if(s[i]=='"') c[i]='_';
else if(s[i]==39) c[i]='-';
else if(s[i]=='Z') c[i]=':';
else if(s[i]=='z') c[i]=';';
else if(s[i]=='X') c[i]='Q';
else if(s[i]=='x') c[i]='q';
else if(s[i]=='C') c[i]='J';
else if(s[i]=='c') c[i]='j';
else if(s[i]=='V') c[i]='K';
else if(s[i]=='v') c[i]='k';
else if(s[i]=='B') c[i]='X';
else if(s[i]=='b') c[i]='x';
else if(s[i]=='N') c[i]='B';
else if(s[i]=='n') c[i]='b';
else if(s[i]=='<') c[i]='W';
else if(s[i]==',') c[i]='w';
else if(s[i]=='>') c[i]='V';
else if(s[i]=='.') c[i]='v';
else if(s[i]=='?') c[i]='Z';
else if(s[i]=='/') c[i]='z';
else c[i]=s[i];
}
puts(c);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: