码迷,mamicode.com
首页 > 其他好文 > 详细

WERTYU UVA - 10082

时间:2021-02-01 12:19:45      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:code   oar   board   may   should   put   fine   replace   pac   

?   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

标签:code   oar   board   may   should   put   fine   replace   pac   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!