ACM YTU 挑战编程 字符串 Problem A: WERTYU
Problem A: WERTYU
Description
A common typing error is to place yourhands on the keyboard one row to the right of the correct position. Then ``Q'' is typed as ``W''
and ``J'' is typed as ``K'' and so on. Your task is to decode a message typed inthis manner.
Input
Input consists ofseveral lines of text. Each line may contain digits, spaces, uppercase letters(except ``Q'', ``A'', ``Z''), or punctuation shown above [except back-quote(`)]. Keys labeled
with words [Tab, BackSp, Control, etc.] are not representedin the input.
Output
You are to replaceeach letter or punctuation symbol by the one immediately to its left on theQWERTY keyboard shown above. Spaces in the input should be echoed in theoutput.
Sample Input
O S, GOMR YPFSU/
Sample Output
I AM FINE TODAY.
/**
* 水题
* 提议就是输入一串字符,输出它在 键盘上前一位的字符 如 输入U 输出的就是Y
* ps:QAZ除外 空格原样输出
*
*/
#include <iostream>
using namespace std;
int main()
{
string s = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
string line;
while(getline(cin,line))
{
for(int i = 0;i<int(line.length());i++)
{
if(line[i]==' ')
cout<<" ";
else
cout<<s[s.find_first_of(line[i])-1];
/**
* string 类的一个成员函数
* s.find_first_of(line[i])
* 找到 line[i] 在(string)s中出现的第一个值并返回(返回类型为int),没有就返回如果没找到就返回string::npos
* 详情参考 http://blog.163.com/chen_dawn/blog/static/1125063201111191617784/
*/
}
cout<<endl;
}
return 0;
}
ACM YTU 挑战编程 字符串 Problem A: WERTYU的更多相关文章
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- CSDN挑战编程——《数学问题》
数学问题 题目详情: 给你两个长度为n的正整数序列分别为{a1,a2,a3...an},{b1,b2,b3...bn},0<ai,bi<=100: 设S=max{x1*a1+x2*a2+x ...
- CSDN挑战编程——《绝对值最小》
绝对值最小 题目详情: 给你一个数组A[n],请你计算出ans=min(|A[i]+A[j]|)(0<=i,j<n). 比如:A={1, 4, -3}, 则: |A[0] + A[0]| ...
- 挑战编程 uva100 3n+1
挑战编程 刘汝佳 的第一道习题 热身题 熟悉下提交格式 题意 #include <iostream> #include <algorithm> using namespace ...
- SHELL脚本编程-字符串处理
SHELL脚本编程-字符串处理 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.字符串切片 [root@node101.yinzhengjie.org.cn ~]# echo { ...
- ACM YTU 《挑战编程》第一章 入门 Problem E: Graphical Editor
Description Graphical editors such as Photoshop allow us to alter bit-mapped images in the same way ...
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem A: The 3n + 1 problem(水题)
Problem A: The 3n + 1 problem Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 14 Solved: 6[Submit][St ...
- 烟大 Contest1025 - 《挑战编程》第二章:数据结构 Problem A: Jolly Jumpers(水题)
Problem A: Jolly Jumpers Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 10 Solved: 4[Submit][Status] ...
随机推荐
- 使用第三方CDN加速服务加载js/css
ASP.NET MVC 3.0 http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.js http://ajax.aspnet ...
- fork和缓冲区
fork在面试中经常被问到,在这里复习一下. frok创建子进程,父子进程共享.text段,子进程获得父进程数据段.堆和栈的副本,由于在fork之后经常跟随者exec,所以很多实现并不执行父进程数据段 ...
- 用C++的类做三种优先队列的实现
学过数据结构的都知道优先队列这种东西,普通的队列是依据入队顺序,先入队的先出队,而优先队列则是依照键值,键值越大(或越小),就越先出队. 所以,优先队列基本支持push,pop,empty,size, ...
- jquery 书写全选反选功能
书写一个后台管理中用到的全选反选功能.代码如下 <!DOCTYPE html> <html lang="en"> <head> <meta ...
- Android项目Tab类型主界面大总结 Fragment+TabPageIndicator+ViewPager
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24740977 Android如今实现Tab类型的界面方式越来越多,今天就把常见的 ...
- oracle强化练习之分组函数
1. 显示平均工资为>2000的职位 select job,avg(sal) from emp group by job having avg(sal)>2500; 2. ...
- uva-10487 - Closest Sums
暴力枚举后去重最后二分加推断找答案 #include<iostream> #include<map> #include<string> #include<cs ...
- linux route命令学习
route命令用于显示和操作IP路由表. 没有增加路由之前,route命令的结果如下, sh-# route Kernel IP routing table Destination Gatew ...
- [Webpack 2] Intro to the Production Webpack Course
There are several lessons that will build on top of this project. It is a fairly standard, small web ...
- hadoop错误org.apache.hadoop.mapred.TaskAttemptListenerImpl Progress of TaskAttempt
错误: org.apache.hadoop.mapred.TaskAttemptListenerImpl: Progress of TaskAttempt 原因: 错误很明显,磁盘空间不足,但郁闷的是 ...