Codeforces 271 Div 2 A Keyboard
题目链接:http://codeforces.com/contest/474/problem/A
解题报告:一个矩形的键盘,上面只有规定的字符,现在按的时候总是会向某个方向按偏,也就是输入一串字符后,这串字符其实不是我要输入的字符,偏的方向只有左跟右,现在给你每次偏的方向跟输入的字符,让你求原来想要的字符串。注意不会出现按到键盘外的情况。
直接键盘上所有的字符先存到一起,然后左偏取的时候+1,右偏取的时候-1就行了。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std; char str[];
int main()
{
char ch[];
char dir[] = "qwertyuiopasdfghjkl;zxcvbnm,./";
while(scanf("%s",ch)!=EOF)
{
scanf("%s",str);
int flag = -;
if(ch[] == 'L') flag = ;
int len = strlen(str),n = strlen(dir);
for(int i = ;i < len;++i)
{
for(int j = ;j < n;++j)
if(dir[j] == str[i])
{
printf("%c",dir[j+flag]);
break;
}
}
puts("");
}
return ;
}
Codeforces 271 Div 2 A Keyboard的更多相关文章
- Codeforces Round #271 (Div. 2)-A. Keyboard
http://codeforces.com/problemset/problem/474/A A. Keyboard time limit per test 2 seconds memory limi ...
- Codeforces 271 Div 2 C. Captain Marmot
题目链接:http://codeforces.com/contest/474/problem/C 解题报告:给一个n,然后输入4*n个平面坐标系上的点,每四个点是一组,每个点有一个中心,这四个点可以分 ...
- Codeforces 271 Div 2 B. Worms
题目链接:http://codeforces.com/contest/474/problem/B 解题报告:给你n个堆,第i个堆有ai个物品,物品的编号从1开始,第一堆的编号从1到a1,第二堆编号从a ...
- codeforces#271 (Div. 2)预处理
B. Worms time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #271 (Div. 2)题解【ABCDEF】
Codeforces Round #271 (Div. 2) A - Keyboard 题意 给你一个字符串,问你这个字符串在键盘的位置往左边挪一位,或者往右边挪一位字符,这个字符串是什么样子 题解 ...
- Codeforces #344 Div.2
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...
- Codeforces #345 Div.1
Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...
- Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...
- Codeforces#441 Div.2 四小题
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...
随机推荐
- Lock的用法,为什么要用?
当多个进程分享数据的时候,对某段程序代码要lock(当对分享数据进行改写的时候). 我们先看些这段代码: namespace ThreadTest { class Program { static b ...
- $(document).ready、body.Onload()和 $(window).load的区别
window.load(function(){...})和body.onload()都存在同样一个问题,那都是在页面所有元素(包括html标签以及引用到得所有图片,Flash等媒体)加载完毕后执行的, ...
- php操作redis
redis的操作很多的,以前看到一个比较全的博客,但是现在找不到了.查个东西搜半天,下面整理一下php处理redis的例子,个人觉得常用一些例子.下面的例子都是基于php-redis这个扩展的. 1, ...
- _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':问题的解决 mysql安装python
在win7下安装了Python后,想安装python-MySQL,使用pip安装出现如下问题: >pip install MySQL-python _mysql.c(42) : fatal er ...
- jQuery学习笔记——弹出对话框
引用jQuery库文件的<script>标签,必须放在引用自定义脚本文件的<script>标签之前.否则,在编写的代码中将不能引用到jQuery框架 <script ty ...
- php的if语句单行与多行
//正确: //错误写法 $b = //if前面不能带 等号
- Xcode文档安装
找到所需文档的下载地址,搜索.dmg 安装位置
- 【Delphi】获取EIP
var EIP: Cardinal; procedure GetEIP(); stdcall; asm pop eax; mov EIP,eax; push eax; end; procedure T ...
- OC-ARC
一. 基本简介 ARC是自iOS 5之后增加的新特性,完全消除了手动管理内存的烦琐,编译器会自动在适当的地方插入适当的retain.release.autorelease语句.你不再需要担心内存管理, ...
- Orchard源码分析(4.1):Orchard.Environment.CollectionOrderModule类
CollectionOrderModule类是一个Autofac模块(Module,将一系列组件和相关的功能包装在一起),而非Orchard模块.其作用是保证多个注册到容器的组件能按FIFO(Firs ...