标签: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 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.
? 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.
O S, GOMR YPFSU/
I AM FINE TODAY.
?? 运用字符传比较。将所有的键盘上的字符存储到一个数组上,循环比较每一个字符是否是与数组上面的对应。若对应打印数组上对应字符位置的前一个字符。若没有打印自己。
#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);
}
}
标签:code oar board may should put fine replace pac
原文地址:https://www.cnblogs.com/3236676588buladuo/p/14350319.html