浙江省赛2015 _ J - Convert QWERTY to Dvorak -> ZOJ 3878
2018-03-11 12:08
344 查看
模拟水题
题目:ZOJ 3878
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:
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;
思路:用switch判断,将每个QWERTY键盘符号转换成Dvorak键盘符号。注意 : getline(cin,s)接收一行string,while(getline(cin,str[cnt++]));接收多行string
代码实现:
小结:模拟水题,刚开始忘记str设为数组了,得了个Segmentation Fault ,然后Presentation Error,因为换行,输入的最后一行没有换行,就不需要输出换行,注意 : 输出结果保持与输入一致。
题目:ZOJ 3878
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:
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;
思路:用switch判断,将每个QWERTY键盘符号转换成Dvorak键盘符号。注意 : getline(cin,s)接收一行string,while(getline(cin,str[cnt++]));接收多行string
代码实现:
#include<bits/stdc++.h> using namespace std; void solve(char s){ switch(s){ //1 case '_':cout<<'{';break; case '-':cout<<'[';break; case '+':cout<<'}';break; case '=':cout<<']';break; //2 case 'Q':cout<<'"';break; case 'q':cout<<'\'';break; case 'W':cout<<'<';break; case 'w':cout<<',';break; case 'E':cout<<'>';break; case 'e':cout<<'.';break; case 'R':cout<<'P';break; case 'r':cout<<'p';break; case 'T':cout<<'Y';break; case 't':cout<<'y';break; case 'Y':cout<<'F';break; case 'y':cout<<'f';break; case 'U':cout<<'G';break; case 'u':cout<<'g';break; case 'I':cout<<'C';break; case 'i':cout<<'c';break; case 'O':cout<<'R';break; case 'o':cout<<'r';break; case 'P':cout<<'L';break; case 'p':cout<<'l';break; case '{':cout<<'?';break; case '[':cout<<'/';break; case '}':cout<<'+';break; case ']':cout<<'=';break; //3 case 'S':cout<<'O';break; case 's':cout<<'o';break; case 'D':cout<<'E';break; case 'd':cout<<'e';break; case 'F':cout<<'U';break; case 'f':cout<<'u';break; case 'G':cout<<'I';break; case 'g':cout<<'i';break; case 'H':cout<<'D';break; case 'h':cout<<'d';break; case 'J':cout<<'H';break; case 'j':cout<<'h';break; case 'K':cout<<'T';break; case 'k':cout<<'t';break; case 'L':cout<<'N';break; case 'l':cout<<'n';break; case ':':cout<<'S';break; case ';':cout<<'s';break; case '"':cout<<'_';break; case '\'':cout<<'-';break; //4 case 'Z':cout<<':';break; case 'z':cout<<';';break; case 'X':cout<<'Q';break; case 'x':cout<<'q';break; case 'C':cout<<'J';break; case 'c':cout<<'j';break; case 'V':cout<<'K';break; case 'v':cout<<'k';break; case 'B':cout<<'X';break; case 'b':cout<<'x';break; case 'N':cout<<'B';break; case 'n':cout<<'b';break; case '<':cout<<'W';break; case ',':cout<<'w';break; case '>':cout<<'V';break; case '.':cout<<'v';break; case '?':cout<<'Z';break; case '/':cout<<'z';break; default : cout<<s; } } int main(int argc, char const *argv[]) { int cnt = 0; string str[200]; while(getline(cin,str[cnt++])); //cout<<"cnt : "<<cnt<<endl; for (int i = 0; i < cnt; ++i) { int length = str[i].size(); for(int j=0;j<length;j++) solve(str[i][j]); if(i!=cnt-1)cout<<endl; } return 0; }
小结:模拟水题,刚开始忘记str设为数组了,得了个Segmentation Fault ,然后Presentation Error,因为换行,输入的最后一行没有换行,就不需要输出换行,注意 : 输出结果保持与输入一致。
相关文章推荐
- 浙江省赛2015 _ G - Lunch Time -> ZOJ - 3875
- ZOJ 3878 Convert QWERTY to Dvorak(浙江省赛2015)
- 浙江省赛 2015 -> A.Ace of Aces
- 数学题ZOJ3870 Team Formation(2015浙江省赛)
- ZOJ 3878 Convert QWERTY to Dvorak(12th 浙江省赛)
- 浙江省赛2015 _ L _ ZOJ 3880
- ZOJ-3878-Convert QWERTY to Dvorak【暴力】【12th浙江省赛】
- ZOJ3872:Beauty of Array(浙江省赛2015)
- 【NOIP2015】求和<C++>
- ZOJ 3878 Convert QWERTY to Dvorak
- 2017浙江省赛 H - Binary Tree Restoring ZOJ - 3965
- UESTC_男神的约会 2015 UESTC Training for Dynamic Programming<Problem J>
- ZOJ-3333-Guess the Price【7th浙江省赛】
- ZOJ 3872 2015省赛D 技巧题
- UESTC_邱老师的脑残粉 2015 UESTC Training for Graph Theory<Problem D>
- zoj 3878 Convert QWERTY to Dvorak【好坑的模拟】
- ZOJ 3878 Convert QWERTY to Dvorak
- <boost -01> boost::filesystem在visual studio 2015的安装/配置方法
- ACM->逻辑判断 ZOJ 3657 The Little Girl who Picks Mushrooms
- ZOJ 3913 Bob wants to pour water ZOJ Monthly, October 2015 - H