WERTYU
2015-07-22 16:34
330 查看
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.
就是键盘错位了,把他换回来。
做法1,像我一样傻傻的一个一个手动换掉。过程我就不详说了。
方法2,把键盘从第一行到第三行一次输入进字符串里,然后判断是否需要替换(有个别字符是不能换的),然后s[i]=s[i-1];
比上面那个好多了- -方法看智商。
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.
就是键盘错位了,把他换回来。
做法1,像我一样傻傻的一个一个手动换掉。过程我就不详说了。
#include<cstdio> #include<cstring> #include<iostream> #include<string> #include<queue> #include<algorithm> using namespace std; char a[1005]; int main() { int i, j, m, n, ans, len; while (gets(a)) { len = strlen(a); for (i = 0; i < len; i++) { if (a[i] == '1') a[i] = '`'; else if (a[i] == '2') a[i] ='1' ; else if (a[i] == '3') a[i] = '2'; else if (a[i] == '4') a[i] = '3'; else if (a[i] == '5') a[i] = '4'; else if (a[i] == '6') a[i] = '5'; else if (a[i] == '7') a[i] = '6'; else if (a[i] == '8') a[i] = '7'; else if (a[i] == '9') a[i] = '8'; else if (a[i] == '0') a[i] = '9'; else if (a[i] == '-') a[i] = '0'; else if (a[i] == '=') a[i] = '-'; else if (a[i] == 'W') a[i] = 'Q'; else if (a[i] == 'E') a[i] = 'W'; else if (a[i] == 'R') a[i] = 'E'; else if (a[i] == 'T') a[i] = 'R'; else if (a[i] == 'Y') a[i] = 'T'; else if (a[i] == 'U') a[i] = 'Y'; else if (a[i] == 'I') a[i] = 'U'; else if (a[i] == 'O') a[i] = 'I'; else if (a[i] == 'P') a[i] = 'O'; else if (a[i] == '[') a[i] = 'P'; else if (a[i] == ']') a[i] = '['; else if (a[i] == '\\') a[i] = ']'; else if (a[i] == 'S') a[i] = 'A'; else if (a[i] == 'D') a[i] = 'S'; else if (a[i] == 'F') a[i] = 'D'; else if (a[i] == 'G') a[i] = 'F'; else if (a[i] == 'H') a[i] = 'G'; else if (a[i] == 'J') a[i] = 'H'; else if (a[i] == 'K') a[i] = 'J'; else if (a[i] == 'L') a[i] = 'K'; else if (a[i] == ';') a[i] = 'L'; else if (a[i] == 39) a[i] = ';'; else if (a[i] == 'X') a[i] = 'Z'; else if (a[i] == 'C') a[i] = 'X'; else if (a[i] == 'V') a[i] = 'C'; else if (a[i] == 'B') a[i] = 'V'; else if (a[i] == 'N') a[i] = 'B'; else if (a[i] == 'M') a[i] = 'N'; else if (a[i] == ',') a[i] = 'M'; else if (a[i] == '.') a[i] = ','; else if (a[i] == '/') a[i] = '.'; } for (i = 0; i < len; i++) cout << a[i]; cout << endl; } return 0; }
方法2,把键盘从第一行到第三行一次输入进字符串里,然后判断是否需要替换(有个别字符是不能换的),然后s[i]=s[i-1];
比上面那个好多了- -方法看智商。
相关文章推荐
- 修改蓝牙广播间隔
- mybatis(七)——mybatis的一二级缓存
- Spark内部通信/akka
- Activity的启动模式
- CentOS iptables 默认配置
- [150722]查找某个时间段的文件和find命令
- client api
- 洛谷-10进军苏联-[再也不坑]【二战2】二战系列2:狼烟四起
- ruby2.2.2在msvc2010上编译
- Winform 获取相对路径 C#
- 【C++】Copy Constructor
- js快速查找字符串某个字符出现次数
- 【Loadrunner】初学Loadrunner——参数化设置(Xml类型)
- ActionBar的覆盖叠加
- C/C++校招笔试面试经典题目总结六
- java获取百度网盘真实下载链接
- 设计模式三大基础模式之工厂模式,单例模式,注册树模式
- jquery ajax配合SpringMVC实现局部刷新DIV
- c#抽象工厂类
- elasticsearch的rest搜索--- 查询