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:
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;
题意分析:给你第一个键盘上字符, 让你对应输出第二个键盘上的字符,用map比较简单,注意键盘上的 | ,因为输入的是有效的字符,所以两个 | 才表示一个有效字符,还有换行字符‘\n’,空格字符,注意着几个不要遗漏,这题在POJ上如果用gets输入的话提交后会出现编译错误,所以我才换的以下的输入方式。
AC代码如下:
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include <iostream>
#include<algorithm>
using namespace std;
map<char,char>dic;
int main()
{
char a;
dic['~'] = '~';
dic['`'] = '`';
dic['1'] = '1';
dic['!'] = '!';
dic['2'] = '2';
dic['@'] = '@';
dic['3'] = '3';
dic['#'] = '#';
dic['4'] = '4';
dic['$'] = '$';
dic['5'] = '5';
dic['%'] = '%';
dic['6'] = '6';
dic['^'] = '^';
dic['7'] = '7';
dic['&'] = '&';
dic['8'] = '8';
dic['*'] = '*';
dic['9'] = '9';
dic['('] = '(';
dic['0'] = '0';
dic[')'] = ')';
dic['_'] = '{';
dic['-'] = '[';
dic['+'] = '}';
dic['='] = ']';
dic['Q'] = '"';
dic['q'] = '\'';
dic['W'] = '<';
dic['w'] = ',';
dic['E'] = '>';
dic['e'] = '.';
dic['R'] = 'P';
dic['r'] = 'p';
dic['T'] = 'Y';
dic['t'] = 'y';
dic['Y'] = 'F';
dic['y'] = 'f';
dic['U'] = 'G';
dic['u'] = 'g';
dic['I'] = 'C';
dic['i'] = 'c';
dic['O'] = 'R';
dic['o'] = 'r';
dic['P'] = 'L';
dic['p'] = 'l';
dic['{'] = '?';
dic['['] = '/';
dic['}'] = '+';
dic[']'] = '=';
dic['|'] = '|';
dic['\\'] = '\\';
dic['A'] = 'A';
dic['a'] = 'a';
dic['S'] = 'O';
dic['s'] = 'o';
dic['D'] = 'E';
dic['d'] = 'e';
dic['F'] = 'U';
dic['f'] = 'u';
dic['G'] = 'I';
dic['g'] = 'i';
dic['H'] = 'D';
dic['h'] = 'd';
dic['J'] = 'H';
dic['j'] = 'h';
dic['K'] = 'T';
dic['k'] = 't';
dic['L'] = 'N';
dic['l'] = 'n';
dic[':'] = 'S';
dic[';'] = 's';
dic['"'] = '_';
dic['\''] = '-';
dic['Z'] = ':';
dic['z'] = ';';
dic['X'] = 'Q';
dic['x'] = 'q';
dic['C'] = 'J';
dic['c'] = 'j';
dic['V'] = 'K';
dic['v'] = 'k';
dic['B'] = 'X';
dic['b'] = 'x';
dic['N'] = 'B';
dic['n'] = 'b';
dic['M'] = 'M';
dic['m'] = 'm';
dic['<'] = 'W';
dic[','] = 'w';
dic['>'] = 'V';
dic['.'] = 'v';
dic['?'] = 'Z';
dic['/'] = 'z';
dic['\n'] = '\n';
dic[' '] = ' ';
/*
char a[200000];
while(gets(a))
{
int len=strlen(a);
for(int i=0;i<len;i++)
printf("%c",dic[a[i]]);
printf("\n);
}
*/
while( (a = getchar()) != EOF)
{
printf("%c",dic[a]);
}
return 0;
}