ZOJ3878(Convert QWERTY to Dvorak)

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 brokenCaps Lockkey, so Edward never presses the brokenCaps 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;

相當噁心的一道題,毫無意義!!!只能說毫無意義!!!,想A的直接複製粘貼吧。。。。別費勁了。。
#include<stdio.h>
#include<iostream>
#include<map>
#include<string.h>
#include<stdlib.h>

using namespace std;

int main()
{
	char str[100005];
	while(gets(str))
	{
		int len = strlen(str);
		for(int i=0;i<len;i++)
		{
			switch(str[i])
			{
				case '_':
					printf("{");
					break;
				case '-':
					printf("[");
					break;
				case '+':
					printf("}");
					break;
				case '=':
					printf("]");
					break;
				case 'Q':
					printf("\"");
					break;
				case 'q':
					printf("'");
					break;
				case 'W':
					printf("<");
					break;
				case 'w':
					printf(",");
					break;
				case 'E':
					printf(">");
					break;
				case 'e':
					printf(".");
					break;
				case 'R':
					printf("P");
					break;
				case 'r':
					printf("p");
					break;
				case 'T':
					printf("Y");
					break;
				case 't':
					printf("y");
					break;
				case 'Y':
					printf("F");
					break;
				case 'y':
					printf("f");
					break;
				case 'U':
					printf("G");
					break;
				case 'u':
					printf("g");
					break;
				case 'I':
					printf("C");
					break;
				case 'i':
					printf("c");
					break;
				case 'O':
					printf("R");
					break;
				case 'o':
					printf("r");
					break;
				case 'P':
					printf("L");
					break;
				case 'p':
					printf("l");
					break;
				case '{':
					printf("?");
					break;
				case '[':
					printf("/");
					break;
				case '}':
					printf("+");
					break;
				case ']':
					printf("=");
					break;
				case 'S':
					printf("O");
					break;
				case 's':
					printf("o");
					break;
				case 'D':
					printf("E");
					break;
				case 'd':
					printf("e");
					break;
				case 'F':
					printf("U");
					break;
				case 'f':
					printf("u");
					break;
				case 'G':
					printf("I");
					break;
				case 'g':
					printf("i");
					break;
				case 'H':
					printf("D");
					break;
				case 'h':
					printf("d");
					break;
				case 'J':
					printf("H");
					break;
				case 'j':
					printf("h");
					break;
				case 'K':
					printf("T");
					break;
				case 'k':
					printf("t");
					break;
				case 'L':
					printf("N");
					break;
				case 'l':
					printf("n");
					break;
				case ':':
					printf("S");
					break;
				case ';':
					printf("s");
					break;
				case '"':
					printf("_");
					break;
				case '\'':
					printf("-");
					break;
				case 'Z':
					printf(":");
					break;
				case 'z':
					printf(";");
					break;
				case 'X':
					printf("Q");
					break;
				case 'x':
					printf("q");
					break;
				case 'C':
					printf("J");
					break;
				case 'c':
					printf("j");
					break;
				case 'V':
					printf("K");
					break;
				case 'v':
					printf("k");
					break;
				case 'B':
					printf("X");
					break;
				case 'b':
					printf("x");
					break;
				case 'N':
					printf("B");
					break;
				case 'n':
					printf("b");
					break;
				case '<':
					printf("W");
					break;
				case ',':
					printf("w");
					break;
				case '>':
					printf("V");
					break;
				case '.':
					printf("v");
					break;
				case '?':
					printf("Z");
					break;
				case '/':
					printf("z");
					break;
				default:
					printf("%c",str[i]);
					break;
			}			
		}
		putchar('\n');		
	}
	return 0;
}

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章