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.
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char *s="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
char c;
while((int)(c=getchar())!=EOF)
{
char *p;
if(p=strchr(s,c))
cout<<*(p-1);
else
cout<<c;
}
return 0;
}
书上的例题看的书写了一个晚上,堪忧
本文介绍了一种常见的键盘输入错误——将手放在键盘上错开一行,导致字符错位的问题,并提供了解码这种错位输入的方法。通过一个简单的C++程序实现了解码功能。
&spm=1001.2101.3001.5002&articleId=78628943&d=1&t=3&u=3491ef82cef74406a9286faf1c7b0dbc)
501

被折叠的 条评论
为什么被折叠?



