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] ...
随机推荐
- Bzoj 3295: [Cqoi2011]动态逆序对 分块,树状数组,逆序对
3295: [Cqoi2011]动态逆序对 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2886 Solved: 924[Submit][Stat ...
- windows ntp安装及调试
Setting up NTP on Windows It's very helpful that Meinberg have provided an installer for the highly- ...
- InetAddress Example program in Java
The InetAddress class has no visible constructors. To create an InetAddress object, you have to use ...
- Intellij IDEA调试
这段时间一直在使用Intellij IDEA, 今天把调试区工具的使用方法记录于此. 先编译好要调试的程序. 1.设置断点 选定要设置断点的代码行,在行号的区域后面单击鼠标左键即可. 2.开启调试会话 ...
- Notepad++强大的代码补全和代码提示功能的方法
最近写项目,经常要打开一些文件去修改一些代码段.那么我的项目都是使用ied大型编辑器去写的,每次修改文件,哪怕是一个标点都要用一分钟时间去打开软件.当然,后来我也考虑到使用记事本,但总感觉不是很爽. ...
- QinQ封装及终结详解
以下内容摘自正在当当网.京东网.卓越网.互动出版网预售,即将正式发售的<华为交换机学习指南>一书(全书近千页).本书是由华为官方授权,国内第一本,也是唯一一本华为交换机权威学习指南,是华为 ...
- (3/18)重学Standford_iOS7开发_Objective-C_课程笔记
第三课: 本节课主要是游戏实现的demo,因此我将把课程中简单的几个编程技巧提取出来,重点介绍如何自己实现作业中的要求. 纸牌游戏实现: ①游戏的进行是模型的一部分(理解什么是模型:Model = W ...
- MobilePhone正则表达式
电话号码正则表达式(支持手机号码,3-4位区号,7-8位直播号码,1-4位分机号) ((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3} ...
- Pilin —— 一个基于Xmpp openfire smack的即时聊天工具
https://github.com/whfcomm/Pilin
- 第一个Android项目——计算器
第一个Android项目——计算器 效果 开始学Android一两个星期了,学习了一下基本的Activity.简单控件及几个简单布局,打算找个东西来练练手,于是就选择发计算器.关于计算器中用到的四则运 ...