首页 > 其他 > 详细

WERTYU UVA - 10082

时间:2021-01-30 21:09:59      阅读:23      评论:0      收藏:0      [点我收藏+]

?   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);
    }
}

WERTYU UVA - 10082

原文:https://www.cnblogs.com/3236676588buladuo/p/14350319.html

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