Convert QWERTY to Dvorak

Source: Internet
Author: User

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:

The QWERTY Layout
The Dvorak Layout
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;
This was inscribed for half a day. The idea is very simple, is more trouble. But it was handed 4 times!! It's all part of a mistake, like. Then I changed the get, then wrote Getline (cin,s) unexpectedly AC.
But the evening seniors gave us a puzzle, write a good simple http://blog.csdn.net/libin56842/article/details/45272869
Our code:
#include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <  Algorithm>using namespace Std;int Main () {string A;  int I,len;  while (Getline (cin,a)) {len=a.size ();  for (i=0;i<len;i++) {if (a[i]== ' Q ') {a[i]= ' ""; Cout<<a[i];}  else if (a[i]== ' Q ') cout<< "'";  else if (a[i]== ' W ') cout<< "<";  else if (a[i]== ' W ') cout<< ",";  else if (a[i]== ' E ') cout<< ">";  else if (a[i]== ' e ') cout<< ".";  else if (a[i]== ' R ') cout<< "P";  else if (a[i]== ' R ') cout<< "P";  else if (a[i]== ' T ') cout<< "Y";  else if (a[i]== ' t ') cout<< "Y";  else if (a[i]== ' Y ') cout<< "F";  else if (a[i]== ' y ') cout<< "F";  else if (a[i]== ' U ') cout<< "G";  else if (a[i]== ' u ') cout<< "G";  else if (a[i]== ' I ') cout<< "C";  else if (a[i]== ' I ') cout<< "C";  else if (a[i]== ' O ') cout<< "R";  else if (a[i]== ' o ') cout<< "R"; else if (a[i]== ' P ') cout<< "L";  else if (a[i]== ' P ') cout<< "L";  else if (a[i]== ' _ ') cout<< "{";  else if (a[i]== '-') cout<< "[";  else if (a[i]== ' + ') cout<< "}";  else if (a[i]== ' = ') cout<< "]";  else if (a[i]== ' {') cout<< "?";  else if (a[i]== ' [') cout<< "/";  else if (a[i]== '} ') cout<< "+";  else if (a[i]== '] ') cout<< "=";  else if (a[i]== ' S ') cout<< "O";  else if (a[i]== ' s ') cout<< "O";  else if (a[i]== ' D ') cout<< "E";  else if (a[i]== ' d ') cout<< "E";  else if (a[i]== ' F ') cout<< "U";  else if (a[i]== ' F ') cout<< "U";  else if (a[i]== ' G ') cout<< "I";  else if (a[i]== ' G ') cout<< "I";  else if (a[i]== ' H ') cout<< "D";  else if (a[i]== ' h ') cout<< "D";  else if (a[i]== ' J ') cout<< "H";  else if (a[i]== ' J ') cout<< "H";  else if (a[i]== ' K ') cout<< "T";  else if (a[i]== ' K ') cout<< "T";  else if (a[i]== ' L ') cout<< "N"; else if (a[i]== ' l ') cout<< "n";  else if (a[i]== ': ') cout<< "S";    else if (a[i]== '; ')  cout<< "S";  else if (a[i]== ' "') cout<<" _ ";  else if (a[i]== ' \ ') cout<< "-";  else if (a[i]== ' Z ') cout<< ":";  else if (a[i]== ' z ') cout<< ";";  else if (a[i]== ' X ') cout<< "Q";  else if (a[i]== ' x ') cout<< "Q";  else if (a[i]== ' C ') cout<< "J";  else if (a[i]== ' C ') cout<< "J";  else if (a[i]== ' V ') cout<< "K";  else if (a[i]== ' V ') cout<< "K";  else if (a[i]== ' B ') cout<< "X";  else if (a[i]== ' B ') cout<< "X";  else if (a[i]== ' N ') cout<< "B";  else if (a[i]== ' n ') cout<< "B";  else if (a[i]== ' < ') cout<< "W";  else if (a[i]== ', ') cout<< "w";  else if (a[i]== ' > ') cout<< "V";    else if (a[i]== '. ')  cout<< "V";    else if (a[i]== '? ')  cout<< "Z";  else if (a[i]== '/') cout<< "z";   else cout<<a[i];   }cout<<endl; }return 0;}
Daniel's Code:
#include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue > #include <map> #include <set> #include <vector> #include <math.h> #include <algorithm >using namespace std, #define LS 2*i#define rs 2*i+1#define up (i,x,y) for (i=x;i<=y;i++) #define DOWN (i,x,y) for (i=x; i>=y;i--) #define MEM (a,x) memset (A,x,sizeof (a)) #define W (a) while (a) #define LL long longconst double pi = acos (-1.0); # Define Len 20005#define mod 19999997const int INF = 0x3f3f3f3f;char s1[]= {"-=_+QWERTYUIOP[]QWERTYUIOP{}ASDFGHJKL; ') Asdfghjkl:\ "ZXCVBNM,./ZXCVBNM<>?"}; Char s2[]= {"[]{} ',. pyfgcrl/=\" <>pyfgcrl?+aoeuidhtns-aoeuidhtns_;qjkxbmwvz:qjkxbmwvz "};char C;char print ( Char c) {for    (int i=0; s1[i]; i++)        if (s1[i]==c)            return s2[i];    return c;} int main () {    W (~scanf ("%c", &c))    printf ("%c", print (c));    return 0;}

Convert QWERTY to Dvorak

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.