码迷,mamicode.com
首页 > 其他好文 > 详细

poj 2538 WERTYU

时间:2014-11-27 22:12:48      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:c++   算法   poj   zoj   编程   

WERTYU
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8492   Accepted: 4063

Description

bubuko.com,布布扣 
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;
}



poj 2538 WERTYU

标签:c++   算法   poj   zoj   编程   

原文地址:http://blog.csdn.net/codeforcer/article/details/41550617

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!