首页 > 其他 > 详细

POJ 之 WERTYU

时间:2014-09-18 21:58:24      阅读:327      评论:0      收藏:0      [点我收藏+]
WERTYU
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8371   Accepted: 4007

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 <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

原文:http://www.cnblogs.com/yspworld/p/3979979.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!