ZOJ Problem Set–1884 WERTYU
2012-05-09 12:09
501 查看
Time Limit: 2 Seconds Memory Limit: 65536 KB
![](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=0000%2F1884%2F1884.jpg)
A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.
Input
Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.
Output
You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.
Sample Input
O S, GOMR YPFSU/
Sample Output
I AM FINE TODAY.
Source: University of Waterloo Local Contest 2001.01.27
![](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=0000%2F1884%2F1884.jpg)
A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.
Input
Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.
Output
You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.
Sample Input
O S, GOMR YPFSU/
Sample Output
I AM FINE TODAY.
Source: University of Waterloo Local Contest 2001.01.27
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
while(getline(cin, s))
{
for(int i = 0; i < s.length(); i++)
{
switch(s[i])
{
case 'A':break;
case 'B':cout<<'V';break;
case 'C':cout<<'X';break;
case 'D':cout<<'S';break;
case 'E':cout<<'W';break;
case 'F':cout<<'D';break;
case 'G':cout<<'F';break;
case 'H':cout<<'G';break;
case 'I':cout<<'U';break;
case 'J':cout<<'H';break;
case 'K':cout<<'J';break;
case 'L':cout<<'K';break;
case 'M':cout<<'N';break;
case 'N':cout<<'B';break;
case 'O':cout<<'I';break;
case 'P':cout<<'O';break;
case 'Q':break;
case 'R':cout<<'E';break;
case 'S':cout<<'A';break;
case 'T':cout<<'R';break;
case 'U':cout<<'Y';break;
case 'V':cout<<'C';break;
case 'W':cout<<'Q';break;
case 'X':cout<<'Z';break;
case 'Y':cout<<'T';break;
case 'Z':break;
case '`':break;
case '1':cout<<'`';break;
case '2':case '3':case '4':case '5':
case '6':case '7':case '8':case '9':cout<<char(s[i] - 1);break;
case '0':cout<<'9';break;
case '-':cout<<'0';break;
case '=':cout<<'-';break;
case '[':cout<<'P';break;
case ']':cout<<'[';break;
case '\\':cout<<']';break;
case ';':cout<<'L';break;
case ',':cout<<'M';break;
case '.':cout<<',';break;
case '/':cout<<'.';break;
case '\'':cout<<';';break;
case ' ':cout<<' ';break;
}
}
cout<<endl;
}
return 0;
}
相关文章推荐
- ZOJ Problem Set – 1056 The Worm Turns
- ZOJ Problem Set–1337 Pi
- ZOJ Problem Set–1514 Fake Tickets
- ZOJ Problem Set–1101 Gamblers
- ZOJ Problem Set–1251 Box of Bricks
- ZOJ Problem Set–1405 Tanning Salon
- ZOJ Problem Set–1879 Jolly Jumpers
- ZOJ Problem Set–1526 Big Number
- ZOJ Problem Set–1180 Self Numbers
- ZOJ Problem Set–1152 A Mathematical Curiosity
- ZOJ Problem Set–1216 Deck
- ZOJ Problem Set–2104 Let the Balloon Rise
- ZOJ Problem Set–2405 Specialized Four-Digit Numbers
- ZOJ Problem Set–1151 Word Reversal
- ZOJ Problem Set–1915 Above Average
- ZOJ Problem Set–2108 Elevator
- ZOJ Problem Set–1109 Language of FatMouse
- ZOJ Problem Set–1292 Integer Inquiry
- ZOJ Problem Set–1760 Doubles
- ZOJ Problem Set–1813 Biker's Trip Odometer