poj 2538 WERTYU

WERTYU

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8492   Accepted: 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;
}
时间: 2024-10-14 05:19:33

poj 2538 WERTYU的相关文章

POJ 2538 WERTYU(水题)

[题目简述]:题意很简单,没有trick. [分析]:其实这题还是挺有趣的,在 算法竞赛入门经典中也有这一题. 详见代码: // 120K 0Ms /* 边学边做 -- */ // 字符串:WERTYU #include<iostream> using namespace std; char *s = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; //注意这里的这个"\"要打两次,不然会被误认为

POJ 之 WERTYU

WERTYU Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8371   Accepted: 4007 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

POJ 2538

#include<string> //#include #include<stdio.h> #include<iostream> using namespace std; char map[]={'`','1','2','3','4','5','6','7','8','9','0','-','=','Q','W','E','R','T','Y','U','I','O','P','[',']','\\','A','S','D','F','G','H','J','K','L

优质题表(机密版)

转载请注明出处:http://www.cnblogs.com/dashuzhilin/p/4556803.html 思维题: poj 1528 poj 1597 poj 2538 poj 2608 poj 2612 poj 2361 poj 2339 poj 2664 uva 10894 uva 10921   uva 10922   uva 10929 uva 10931   uva 10800   uva 10878 uva 10976   uva 10323   uva 201 poj 2

POJ 3449 Geometric Shapes --计算几何,线段相交

题意: 给一些多边形或线段,输出与每一个多边形或线段的有哪一些多边形或线段. 解法: 想法不难,直接暴力将所有的图形处理成线段,然后暴力枚举,相交就加入其vector就行了.主要是代码有点麻烦,一步一步来吧. 还有收集了一个线段旋转的函数. Vector Rotate(Point P,Vector A,double rad){ //以P为基准点把向量A旋转rad return Vector(P.x+A.x*cos(rad)-A.y*sin(rad),P.y+A.x*sin(rad)+A.y*co

【POJ 2400】 Supervisor, Supervisee(KM求最小权匹配)

[POJ 2400] Supervisor, Supervisee(KM求最小权匹配) Supervisor, Supervisee Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2538   Accepted: 719 Description Suppose some supervisors each get to hire a new person for their department. There are N

POJ - 3186 Treats for the Cows (区间DP)

题目链接:http://poj.org/problem?id=3186 题意:给定一组序列,取n次,每次可以取序列最前面的数或最后面的数,第n次出来就乘n,然后求和的最大值. 题解:用dp[i][j]表示i~j区间和的最大值,然后根据这个状态可以从删前和删后转移过来,推出状态转移方程: dp[i][j]=max(dp[i+1][j]+value[i]*k,dp[i][j-1]+value[j]*k) 1 #include <iostream> 2 #include <algorithm&

POJ 2533 - Longest Ordered Subsequence(最长上升子序列) 题解

此文为博主原创题解,转载时请通知博主,并把原文链接放在正文醒目位置. 题目链接:http://poj.org/problem?id=2533 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK)

POJ——T2271 Guardian of Decency

http://poj.org/problem?id=2771 Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5932   Accepted: 2463 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is