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] ...
随机推荐
- QT5.1在Windows下 出现QApplication: No such file or directory 问题的解决办法
QT5.0.1在Windows下 出现QApplication: No such file or directory 问题的解决办法 分类: 编程语言学习 软件使用 QT编程学习2013-03-07 ...
- Ubuntu 下安装Kibana和logstash
原文地址:http://www.cnblogs.com/saintaxl/p/3946667.html 简单来讲他具体的工作流程就是 logstash agent 监控并过滤日志,将过滤后的日志内容发 ...
- OpenCV SIFT原理与源码分析
http://blog.csdn.net/xiaowei_cqu/article/details/8069548 SIFT简介 Scale Invariant Feature Transform,尺度 ...
- Shell脚本语言与编译型语言的差异
大体上,可以将程序设计语言可以分为两类:编译型语言和解释型语言. 编译型语言 很多传统的程序设计语言,例如Fortran.Ada.Pascal.C.C++和Java,都是编译型语言.这类语言需要预先将 ...
- c# 扩展方法奇思妙用集锦
本文转载:http://www.cnblogs.com/ldp615/archive/2009/08/07/1541404.html 其中本人觉得很经典的:c# 扩展方法奇思妙用基础篇五:Dictio ...
- 显示、隐藏 PowerShell
以下是一个快速实现该需求的 module.只要将以下代码复制粘贴到 Documents\WindowsPowerShell\Packages\PowerShell\PowerShell.psm1 即可 ...
- 怎样在win7下装ubuntu(硬盘版安装)
1)首先还是分区,在计算机上右键--管理--磁盘管理 装Ubuntu分配的硬盘大小最好是(20G以上)不要太小,这里请注意,ubuntu和windows文件系统全然不同,所以我们划好要给ubuntu的 ...
- json xmpp
https://github.com/lamfire/jspp http://blog.csdn.net/nomousewch/article/category/823687 http://my.os ...
- 在内核外编写的linux驱动程序MAKEFILE
一般都是这么写: ifneq ($(KERNELRELEASE),) obj-m := else KERNELDIR ?= /lib/modules/$(shell uname -r)/build ...
- 移动測试技术保护源码!解码全球首款移动端白盒測试工具ThreadingTest (文章转自己主动点科技)
作者 智晓锋 - 2014/07/14 自从斯诺登曝光美监听丑闻事件之后,我国政府就将信息安全问题上升到了国家安全的高度.基于此.国内的一家创业公司推出了智能型Android真机白盒測试以及开发辅助类 ...