链接:

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:

(字符串  键盘转换)Convert QWERTY to Dvorak -- zoj -- 5526-LMLPHP
The QWERTY Layout

(字符串  键盘转换)Convert QWERTY to Dvorak -- zoj -- 5526-LMLPHP
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[] = "_-+=qWwEeRrTtYyUuIiOoPp{[}]SsDdFfGgHhJjKkLl:;'ZzXxCcVvBbNnMm<,>.?/";
char s2[] = "{[}]'<,>.PpYyFfGgCcRrLl?/+=OoEeUuIiDdHhTtNnSs-:;QqJjKkXxBbMmWwVvZz"; int main()
{
char s[N], ch='"'; while(gets(s))
{
int i;
for(i=; s[i]; i++)
{
int flag=, a;
char ss[]; ss[] = s[i];
ss[] = '\0'; if(s[i]==ch)
printf("_"), flag = ;
else if(s[i]=='Q')
printf("%c", ch), flag = ;
else if(strstr(s1, ss))
{
a = strstr(s1, ss) - s1;
printf("%c", s2[a]);
flag = ;
} if(flag==) printf("%c", s[i]);
} printf("\n");
}
return ;
}
05-02 06:18