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.
InputInput 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.
OutputYou 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<stdio.h>
using namespace std;
char s[]="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
///把整个键盘输入。。。。。。。。这^里两个\才代表一个\;
int main()
{
char c;int i;
while(scanf("%c",&c)!=EOF)
{///C++的cin>>输入竟然会WA!!!哭辽.....
int flag=0;
for(i=0;s[i]!='\0';i++)
{
if(c==s[i])
{///找到就输出前一个符号
flag=1;
printf("%c",s[i-1]);
}
}
if(flag==0)///定义的键盘上没有这个符号
printf("%c",c);///就直接输出就好啦~不用换行~
}
}
inline char gc()
{
static char buff[100000000],*S=buff,*T=buff;
return S==T&&(T=(S=buff)+fread(buff,1,100000000,stdin),S==T)?EOF:*S++;
}