博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
九度OJ 1093:WERTYU (翻译)
阅读量:4206 次
发布时间:2019-05-26

本文共 1753 字,大约阅读时间需要 5 分钟。

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:1563

解决:609

题目描述:

    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 punctuation 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
#include
#include
char keyboard[]={'`','1','2','3','4','5','6','7','8','9','0','-','=','Q','W','E','R','T','Y','U','I','O','P','[',']','\\','A','S','D','F','G','H','J','K','L',';','\'','Z','X','C','V','B','N','M',',','.','/'}; int main(){ char string[1000]; int i,j; while(gets(string)) { for(i = 0;i < strlen(string);i++){ if(string[i] == ' '){ printf(" "); } else{ for(j = 0;j < strlen(keyboard);j++){ if(string[i] == keyboard[j]){ printf("%c",keyboard[j-1]); break; } } } } printf("\n"); } return 0;}/************************************************************** Problem: 1093 User: liangrx06 Language: C Result: Accepted Time:0 ms Memory:912 kb****************************************************************/

转载地址:http://ffeli.baihongyu.com/

你可能感兴趣的文章
按照字符读写文件
查看>>
读写文件中字符串的函数
查看>>
按照块的方式操作文件
查看>>
清除和设置文件缓冲区,文件随机读写
查看>>
C语言函数库:动态链接库与静态链接库
查看>>
c++中初学者易犯错模型
查看>>
c++与c语言的关系
查看>>
c++中的namespace命名空间
查看>>
c++相对c语言的增强之~实用性增强,register关键字增强,变量检测增强
查看>>
c++相对于c语言中的结构体增强
查看>>
新增bool类型关键字
查看>>
三目运算符在c和c++编译器的表现
查看>>
c++与c语言中的const关键字
查看>>
c++中的const和define的异同之处
查看>>
c++中的引用
查看>>
c++中复杂类型的引用
查看>>
c++中引用的本质
查看>>
函数返回值是引用的情况。
查看>>
指针的引用
查看>>
c++中的const,即常引用
查看>>