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:
The QWERTY 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;
Author: ZHOU, Yuchen
Source: The 12th Zhejiang Provincial Collegiate Programming Contest
题目意思就是键盘从上面那个原来的换成下面这个现在的,输出新的字符串。
/*
* Copyright (c) 2016, 烟台大学计算机与控制工程学院
* All rights reserved.
* 文件名称:zoj.cpp
* 作 者:单昕昕
* 完成日期:2016年4月2日
* 版 本 号:v1.0
*/
#include <iostream>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
char s[100000];//这个数组要开大!不然会错!题目里说的是100KB呀喂!不是100阿!
void f(char c)//每种情况枚举
{
if(c=='Q') cout<<"\"";
else if(c=='q') cout<<"'";
else if(c=='W') cout<<"<";
else if(c=='w') cout<<",";
else if(c=='E') cout<<">";
else if(c=='e') cout<<".";
else if(c=='R') cout<<"P";
else if(c=='r') cout<<"p";
else if(c=='T') cout<<"Y";
else if(c=='t') cout<<"y";
else if(c=='Y') cout<<"F";
else if(c=='y') cout<<"f";
else if(c=='U') cout<<"G";
else if(c=='u') cout<<"g";
else if(c=='I') cout<<"C";
else if(c=='i') cout<<"c";
else if(c=='O') cout<<"R";
else if(c=='o') cout<<"r";
else if(c=='P') cout<<"L";
else if(c=='p') cout<<"l";
else if(c=='{') cout<<"?";
else if(c=='[') cout<<"/";
else if(c=='}') cout<<"+";
else if(c==']') cout<<"=";
else if(c=='-') cout<<"[";
else if(c=='_') cout<<"{";
else if(c=='=') cout<<"]";
else if(c=='+') cout<<"}";
else if(c=='S') cout<<"O";
else if(c=='s') cout<<"o";
else if(c=='D') cout<<"E";
else if(c=='d') cout<<"e";
else if(c=='F') cout<<"U";
else if(c=='f') cout<<"u";
else if(c=='G') cout<<"I";
else if(c=='g') cout<<"i";
else if(c=='H') cout<<"D";
else if(c=='h') cout<<"d";
else if(c=='J') cout<<"H";
else if(c=='j') cout<<"h";
else if(c=='K') cout<<"T";
else if(c=='k') cout<<"t";
else if(c=='L') cout<<"N";
else if(c=='l') cout<<"n";
else if(c==':') cout<<"S";
else if(c==';') cout<<"s";
else if(c=='S') cout<<"O";
else if(c=='s') cout<<"o";
else if(c=='\'') cout<<"-";//格式符要多加一个“\”
else if(c=='"') cout<<"_";
else if(c=='Z') cout<<":";
else if(c=='z') cout<<";";
else if(c=='X') cout<<"Q";
else if(c=='x') cout<<"q";
else if(c=='C') cout<<"J";
else if(c=='c') cout<<"j";
else if(c=='V') cout<<"K";
else if(c=='v') cout<<"k";
else if(c=='B') cout<<"X";
else if(c=='b') cout<<"x";
else if(c=='N') cout<<"B";
else if(c=='n') cout<<"b";
else if(c=='<') cout<<"W";
else if(c==',') cout<<"w";
else if(c=='>') cout<<"V";
else if(c=='.') cout<<"v";
else if(c=='?') cout<<"Z";
else if(c=='/') cout<<"z";
else cout<<c;
}
int main()
{
int i;
while(gets(s))//不能cin,因为有空格
{
for(i=0; s[i]!='\0'; ++i)
f(s[i]);
cout<<endl;
}
return 0;
}
哎,坑爹的100KB,开小了就报这个错:
手打每种情况也不容易呀喂~