zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502

 The 12th Zhejiang Provincial Collegiate Programming Contest - J
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 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:

Qwerty Layout
The QWERTY Layout

Dvorak 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;


分析:

直接打表模拟对照输出即可。

AC代码:

 1 #include <iostream>

 2 #include <stdio.h>

 3 #include <string.h>

 4 #include <stack>

 5 #include <queue>

 6 #include <map>

 7 #include <set>

 8 #include <vector>

 9 #include <math.h>

10 #include <algorithm>

11 using namespace std;

12 #define ls 2*i

13 #define rs 2*i+1

14 #define up(i,x,y) for(i=x;i<=y;i++)

15 #define down(i,x,y) for(i=x;i>=y;i--)

16 #define mem(a,x) memset(a,x,sizeof(a))

17 #define w(a) while(a)

18 #define LL long long

19 const double pi = acos(-1.0);

20 #define Len 20005

21 #define mod 19999997

22 const int INF = 0x3f3f3f3f;

23 

24 char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};

25 char s2[]= {"[]{}',.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};

26 char c;

27 

28 char print(char c)

29 {

30     for(int i=0; s1[i]; i++)

31         if(s1[i]==c)

32             return s2[i];

33     return c;

34 }

35 int main()

36 {

37     w(~scanf("%c",&c))

38     printf("%c",print(c));

39 

40     return 0;

41 }
View Code

 

你可能感兴趣的:(programming)