链接:

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5526

 

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 Lockkey. 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;

 

 

 

代码:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define N 100000

char s1[100] = "_-+=qWwEeRrTtYyUuIiOoPp{[}]SsDdFfGgHhJjKkLl:;'ZzXxCcVvBbNnMm<,>.?/";
char s2[100] = "{[}]'<,>.PpYyFfGgCcRrLl?/+=OoEeUuIiDdHhTtNnSs-:;QqJjKkXxBbMmWwVvZz";

int main()
{
    char s[N], ch='"';

    while(gets(s))
    {
        int i;
        for(i=0; s[i]; i++)
        {
            int flag=0, a;
            char ss[10];

            ss[0] = s[i];
            ss[1] = '\0';

            if(s[i]==ch)
                printf("_"), flag = 1;
            else if(s[i]=='Q')
                printf("%c", ch), flag = 1;
            else if(strstr(s1, ss))
            {
                a = strstr(s1, ss) - s1;
                printf("%c", s2[a]);
                flag = 1;
            }

            if(flag==0) printf("%c", s[i]);
        }

        printf("\n");
    }
    return 0;
}

 

posted on 2015-08-22 09:58  栀蓝  阅读(646)  评论(0编辑  收藏  举报

levels of contents