ACM Learning process-zoj3878 Convert QWERTY to Dvorak (Hash && analog)

Source: Internet
Author: User

Description

Edward, a poor copy typist, is a user of the Dvorak Layout. But now he had only a QWERTY Keyboard with a broken Caps LockKey, so Edward never presses the broken Caps LockKey. 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;

The problem is that the direct violent hand hits two tables and maps the map.

Code:

#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath > #include <algorithm> #include <set> #include <map> #include <queue> #include <string>        Using namespace Std;char from[100] = {' ~ ', '! ', ' @ ', ' # ', ' $ ', '% ', ' ^ ', ' & ', ' * ', ' (', ') ', ' _ ', ' + ', "', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' 0 ', '-', ' = ', ' Q ', ' W ', ' E ', ' R ', ' T ', ' Y ', ' U ', ' I ', ' O ', ' P  ', ' {', '} ', ' | ', ' q ', ' W ', ' e ', ' r ', ' t ', ' y ', ' u ', ' i ', ' o ', ' P ', ' [', '] ', ' \ \ ', ' A ', ' S ', ' D ', ' F ', ' G ', ' H ', ' J ', ' K ', ' l ', ': ', ' ' ', ' a ', ' s ', ' d ', ' f ', ' g ', ' H ', ' J ', ' K ', ' l ', '; ', ' \ ', ' Z ', ' X ', ' C ', ' V ', '        B ', ' n ', ' m ', ' < ', ' > ', '? ', ' Z ', ' x ', ' C ', ' V ', ' b ', ' n ', ' m ', ', ', '. ', '/', '};char to[100] = { ' ~ ', '! ', ' @ ', ' # ', ' $ ', '% ', ' ^ ', ' & ', ' * ', ' (', ' ') ', ' {', '} ', ' ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' 0 ', ' [', '] ', ' ' ', ' < ', ' > ', ' P ', ' Y ', ' F ', ' G ', ' C ', ' R ', ' L ', '? ', ' + ', ' | ', ' \ ', ', ', '. ', ' P ', ' Y ', ' F ', ' G ', ' C ', ' R ', ' L ', ' /', ' = ', ' \ \ ', ' A ', ' o ', ' E ', ' U ', ' I ', ' d ', ' h ', ' t ', ' N ', ' S ', ' _ ', ' A ', ' o ', ' e ', ' u ', ' I ', ' d ', ' h ', ' T ' , ' n ', ' s ', '-', ': ', ' Q ', ' J ', ' K ', ' X ', ' B ', ' m ', ' W ', ' V ', ' Z ', '; ', ' Q ', ' J ', ' K ', ' X ', ' B ', ' m ', ' w ', '    V ', ' z ', '};char str;int main () {//freopen ("test.in", "R", stdin);    Map<char, char> Hash;    for (int i = 0; i < ++i) Hash[from[i]] = to[i];        while ((str = GetChar ()) = EOF) {if (str = = ' \ n ') printf ("\ n");    else printf ("%c", Hash[str]); } return 0;}

ACM Learning process-zoj3878 Convert QWERTY to Dvorak (Hash && analog)

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.