poj 2538 WERTYU

it2024-04-14  20

WERTYU Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6731 Accepted: 3121

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>using namespace std;int main(){char keyboard[50]={'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',';','\'','Z','X','C','V','B','N','M',',','.','/' };int i,j;char input[100];while(gets(input)) {for(i=0;i<strlen(input);i++) {for(j=0;j<50;j++) {if(input[i]=='') { cout<<"";break; } else if(input[i]==keyboard[j]) { cout<<keyboard[j-1];break; } } } cout<<endl; }return 0;}

转载于:https://www.cnblogs.com/w0w0/archive/2011/11/22/2258582.html

最新回复(0)