您的位置:首页 > 其它

poj 2538 WERTYU

2014-11-27 18:41 225 查看
WERTYU

Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 8492Accepted: 4063
Description



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.


水题。。。

#include <iostream>
#include <string.h>
using namespace std;
int main(){
char ss[10000],s;
while (gets(ss)){
int len=strlen(ss),i=0;
while (i<len){
s=ss[i++];
if (s=='W')	cout<<'Q';
else if (s=='E')	cout<<'W';
else if (s=='R')	cout<<'E';
else if (s=='T')	cout<<'R';
else if (s=='Y')	cout<<'T';
else if (s=='U')	cout<<'Y';
else if (s=='I')	cout<<'U';
else if (s=='O')	cout<<'I';
else if (s=='P')	cout<<'O';
else if (s=='[')	cout<<'P';
else if (s==']')	cout<<'[';
else if (s=='\\')	cout<<']';

else if (s=='S')	cout<<'A';
else if (s=='D')	cout<<'S';
else if (s=='F')	cout<<'D';
else if (s=='G')	cout<<'F';
else if (s=='H')	cout<<'G';
else if (s=='J')	cout<<'H';
else if (s=='K')	cout<<'J';
else if (s=='L')	cout<<'K';
else if (s==';')	cout<<'L';
else if(s=='\'')	cout<<';';

else if (s=='X')	cout<<'Z';
else if (s=='C')	cout<<'X';
else if (s=='V')	cout<<'C';
else if (s=='B')	cout<<'V';
else if (s=='N')	cout<<'B';
else if (s=='M')	cout<<'N';
else if (s==',')	cout<<'M';
else if (s=='.')	cout<<',';
else if (s=='/')	cout<<'.';

else if (s=='2')	cout<<'1';
else if (s=='3')	cout<<'2';
else if (s=='4')	cout<<'3';
else if (s=='5')	cout<<'4';
else if (s=='6')	cout<<'5';
else if (s=='7')	cout<<'6';
else if (s=='8')	cout<<'7';
else if (s=='9')	cout<<'8';
else if (s=='0')	cout<<'9';
else if (s=='-')	cout<<'0';
else if (s=='=')	cout<<'-';

else
cout<<s;
}
cout<<endl;
//cin.getline(ss,10000);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: