2013
12-12

# 九度-1093-WERTYU[解题代码]

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

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.

O S, GOMR YPFSU/

I AM FINE TODAY.

cpp 代码如下：
#include<iostream>
#include<string>
using namespace std;
string s1="1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
string s2;
char a[128];
void Init()
{
for(int i=1;i<s1.length();i++)
a[s1[i]]=s1[i-1];
a[' ']=' ';
}
int main()
{
Init();
int i;
while(getline(cin,s2))
{
for(i=0;i<s2.length();i++)
{
cout<<a[s2[i]];
}
cout<<endl;
}
return 0;
}
/**************************************************************
Problem: 1093
User: coder
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/