WERTYU UVA - 10082

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

HINT

​​   运用字符传比较。将所有的键盘上的字符存储到一个数组上,循环比较每一个字符是否是与数组上面的对应。若对应打印数组上对应字符位置的前一个字符。若没有打印自己。

Accepted

#include<stdio.h>
#include<string.h>

int main()
{
    char s[80]="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
    char ch;
    int len=strlen(s);
    while(scanf("%c",&ch)!=EOF)
    {
        int flag=0;
        for(int i=0;i<len;i++)
        {
            if(ch==s[i])
                {
                    printf("%c",s[i-1]);
                    flag=1;
                    break;
                }
        }
        if(!flag)putchar(ch);
    }
}

上一篇:关于微信小程序布局排列


下一篇:再见了,CSDN的搬运党们