首页 > 代码库 > POJ 之 WERTYU

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 "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 <stdio.h>#include <string.h>#include <algorithm>using namespace std;char s[1000000];int main(){    char t[10000];	int i, j;	int len;   //定义区    s[‘1‘]=‘~‘; s[‘2‘]=‘1‘; s[‘3‘]=‘2‘; s[‘4‘]=‘3‘; s[‘5‘]=‘4‘; s[‘6‘]=‘5‘; s[‘7‘]=‘6‘; s[‘8‘]=‘7‘;	s[‘9‘]=‘8‘; s[‘0‘]=‘9‘; s[‘-‘]=‘0‘; s[‘=‘]=‘-‘;	s[‘W‘]=‘Q‘; s[‘E‘]=‘W‘; s[‘R‘]=‘E‘; s[‘T‘]=‘R‘;  s[‘Y‘]=‘T‘;  s[‘U‘]=‘Y‘;	s[‘I‘]=‘U‘; s[‘O‘]=‘I‘; s[‘P‘]=‘O‘; s[‘[‘]=‘P‘; s[‘]‘]=‘[‘;	s[‘\\‘]=‘]‘;        s[‘\‘‘]=‘;‘;	s[‘S‘]=‘A‘; s[‘D‘]=‘S‘; s[‘F‘]=‘D‘; s[‘G‘]=‘F‘; s[‘H‘]=‘G‘; s[‘J‘]=‘H‘; s[‘K‘]=‘J‘; s[‘L‘]=‘K‘; s[‘;‘]=‘L‘;	s[‘X‘]=‘Z‘; s[‘C‘]=‘X‘; s[‘V‘]=‘C‘; s[‘B‘]=‘V‘; s[‘N‘]=‘B‘; s[‘M‘]=‘N‘; s[‘,‘]=‘M‘; s[‘.‘]=‘,‘; s[‘/‘]=‘.‘;	while(gets(t)!=NULL)	{		len = strlen(t);        for(i=0; i<len; i++)        {			if(t[i]==‘ ‘)			{				printf(" ");			}			else			{				printf("%c", s[t[i]] );			}		}		printf("\n");	}	return 0;}

 

POJ 之 WERTYU