Codeforces Round #271 (Div. 2)-A. Keyboard
http://codeforces.com/problemset/problem/474/A
2 seconds
256 megabytes
standard input
standard output
Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:
qwertyuiop
asdfghjkl;
zxcvbnm,./
Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately. He accidentally moved both his hands with one position to the left or to the right. That means that now he presses not a button he wants, but one neighboring button (left or right, as specified in input).
We have a sequence of characters he has typed and we want to find the original message.
First line of the input contains one letter describing direction of shifting ('L' or 'R' respectively for left or right).
Second line contains a sequence of characters written by Mole. The size of this sequence will be no more than 100. Sequence contains only symbols that appear on Mole's keyboard. It doesn't contain spaces as there is no space on Mole's keyboard.
It is guaranteed that even though Mole hands are moved, he is still pressing buttons on keyboard and not hitting outside it.
Print a line that contains the original message.
R
s;;upimrrfod;pbr
allyouneedislove
解题思路:模拟手在标准键盘上面输入字符,L左移一格,R右移一格
1 #include <stdio.h>
2 #include <string.h>
3
4 char c[] = {
5 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
6 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
7 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/'
8 };
9
int main(){
int i, j, len, pos;
char to, str[];
while(scanf("%c", &to) != EOF){
getchar();
gets(str);
len = strlen(str);
if(to == 'R'){
for(i = ; i< len; i++){
for(j = ; j < ; j++){
if(str[i] == c[j]){
if(j <= ){
printf("%c", c[(j + ) % ]);
}
else if(j <= ){
printf("%c", c[(j + ) % ]);
}
else{
printf("%c", c[(j + ) % ]);
}
}
}
}
}
else if(to == 'L'){
for(i = ; i< len; i++){
for(j = ; j < ; j++){
if(str[i] == c[j]){
if(j <= ){
printf("%c", c[(j + ) % ]);
}
else if(j <= ){
printf("%c", c[(j + ) % ]);
}
else{
printf("%c", c[(j + ) % ]);
}
}
}
}
}
printf("\n");
}
return ;
54 }
Codeforces Round #271 (Div. 2)-A. Keyboard的更多相关文章
- Codeforces Round #271 (Div. 2)题解【ABCDEF】
Codeforces Round #271 (Div. 2) A - Keyboard 题意 给你一个字符串,问你这个字符串在键盘的位置往左边挪一位,或者往右边挪一位字符,这个字符串是什么样子 题解 ...
- Codeforces Round #271 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/474 A题:Keyboard 模拟水题. 代码例如以下: #include <iostream> #include ...
- Codeforces Round #271 (Div. 2)
A. Keyboard 题意:一个人打字,可能会左偏一位,可能会右偏一位,给出一串字符,求它本来的串 和紫书的破损的键盘一样 #include<iostream> #include< ...
- Codeforces Round #271 (Div. 2) F. Ant colony (RMQ or 线段树)
题目链接:http://codeforces.com/contest/474/problem/F 题意简而言之就是问你区间l到r之间有多少个数能整除区间内除了这个数的其他的数,然后区间长度减去数的个数 ...
- Codeforces Round #271 (Div. 2) D. Flowers (递推)
题目链接:http://codeforces.com/problemset/problem/474/D 用RW组成字符串,要求w的个数要k个连续出现,R任意,问字符串长度为[a, b]时,字符串的种类 ...
- Codeforces Round #271 (Div. 2) E题 Pillars(线段树维护DP)
题目地址:http://codeforces.com/contest/474/problem/E 第一次遇到这样的用线段树来维护DP的题目.ASC中也遇到过,当时也非常自然的想到了线段树维护DP,可是 ...
- Codeforces Round #271 (Div. 2) F题 Ant colony(线段树)
题目地址:http://codeforces.com/contest/474/problem/F 由题意可知,最后能够留下来的一定是区间最小gcd. 那就转化成了该区间内与区间最小gcd数相等的个数. ...
- Codeforces Round #271 (Div. 2)-B. Worms
http://codeforces.com/problemset/problem/474/B B. Worms time limit per test 1 second memory limit pe ...
- Codeforces Round #271 (Div. 2) F ,E, D, C, B, A
前言:最近被线段树+简单递推DP虐的体无完肤!真是弱! A:简单题,照着模拟就可以,题目还特意说不用处理边界 B:二分查找即可,用lower_lound()函数很好用 #include<stri ...
随机推荐
- Linux下配置 禅道 (项目管理系统)
1.官网下载源码 2.解析一个新的子域名,然后到linux服务器上新建一个站点 3.将下载的文件上传至linux服务器(新建站点的时候已经在 /home/wwwroot/ 里建好了域名对应的文件夹,将 ...
- TP5之查询那些事
1.使用 model 查询,查出的类型为 对象 $a 是一个对象,使用 $a->name 的方式来获取 对象里的属性 2.使用 db 查询,查询出的是 数组 $b 是一个数组,使用 $b['na ...
- ACM心理过程
ACM 都已经一个学期过去了,然后还是很菜很菜,比起别人真的是差到一种境界好么???因为自身的太多原因,因为学的不够精,因为懒惰,因为学习的方法,因为自身对未来的不渴望.因为自满,因为自己的自甘堕落, ...
- vs 对网站和项目使用IIS Express 的64位版
- C# 文件操作 全收录 追加、拷贝、删除、移动文件、创建目录、递归删除文件夹及文件....
本文收集了目前最为常用的C#经典操作文件的方法,具体内容如下:C#追加.拷贝.删除.移动文件.创建目录.递归删除文件夹及文件.指定文件夹下 面的所有内容copy到目标文件夹下面.指定文件夹下面的所有内 ...
- 转 open_cursors参数设置调优
https://www.cnblogs.com/Peyton-for-2012/archive/2013/05/07/3065058.html
- 转 OUI and OPatch Do Not Recognize JDK/JRE on Windows
issue 1: 新覆盖的opatch 提示,无法opatch 报错 此时不应有1.6 D:\app\Administrator\product\11.2.0\dbhome_1\OPatch\ocm\ ...
- 判断EditText输入的字符串中是否包含有emoji表情
我们在实际的开发中经常需要用到EditText 但是有一个不好的地方就是我们在前端用EditText输入了带有emoji表情的字符串之后 服务器是无法识别的,这就需要我们前端根据需求来决定表情的去留, ...
- javaoo面向对象
- WPF学习04:2D绘图 使用Shape绘基本图形
我们将使用Shape进行基本图形绘制. 例子 一个可移动的矩形方框: XAML代码: <Window x:Class="Shape.MainWindow" xmlns=&qu ...