Convert QWERTY to Dvorak Time limit: 2 Seconds Memory Limit: 65536 KB
Edward, a poor copy typist, is a user of the Dvorak Layout. But now he had only a QWERTY Keyboard with a broken Caps Lock key, so Edward never presses the broken Caps Lock key. Luckily, all of the other keys in the QWERTY keyboard work well. Every day, he had 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 is in the following:
Input
A QWERTY document Edward typed. The document has no more than kibibytes. And there is no invalid characters in the document.
Output
The Dvorak document.
Sample Input
JGW Gqm ANDPW a h.soav patsfk f;doenfk gq.d slpt a x,dokt vdtnsaohekjd Yspps,glu pgld; AOD yso kd;kgluz1234567890 ' [Email protected]#$%^&* ()} ']_+-=zqqwewe{[\| Anihdyf.,bt/abcdefuvwxyz
Sample Output
Hi, I ' m Abel, a Dvorak Layout user. But I ' ve only a Qwerty keyboard. The following lines is for testing:1234567890 ' [email protected]#$%^&* () +_-={}[]: ' <>,.? /\| abcdefuvwxyzaxje>ugk,qf;
Problem Solving Ideas:
Direct simulation on the line.
#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;char map[2000005]; Char xx[]={"-=_+QWERTYUIOP[]QWERTYUIOP{}ASDFGHJKL; Asdfghjkl:\ "ZXCVBNM,./ZXCVBNM<>?"}; Char yy[]={"[]{} ',. pyfgcrl/=\" <>pyfgcrl?+aoeuidhtns-aoeuidhtns_;qjkxbmwvz:qjkxbmwvz "};int main () {while ( Gets (map)!=null {int j;int len=strlen (map), for (int i=0;i<len;i++) {J=0;bool cc=0;while (Xx[j]) {if (Xx[j]==map[i]) { cc=1;printf ("%c", Yy[j]); else{j++;}} if (cc==0) printf ("%c", Map[i]);} printf ("\ n");} return 0;}
ZOJ 3878-convert QWERTY to Dvorak "analog"