WERTYU

来源:互联网 发布:c语言读文本文件 编辑:程序博客网 时间:2024/05/01 21:08
Problem Description

A common typing error is to place the hands on the keyboard one rowto 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 inthis 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 (`)]. Keyslabelled with words [Tab, BackSp, Control, etc.] are notrepresented in the input.

Output
You are to replace each letter orpunctuation symbol by the one immediately to its left on the QWERTYkeyboard shown above. Spaces in the input should be echoed in theoutput.

Sample Input
O S, GOMRYPFSU/

Sample Output
I AM FINETODAY.


#include <stdio.h>#include <stdlib.h>int main(){    char s[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";    int c;    char* p;    while((c=getchar())!=EOF)    {        p = s;        while(*p)        {            if(*p == c)break;            p++;        }        if(*p)putchar(p[-1]);        else putchar(c);    }    return 0;}


0 0
原创粉丝点击