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 ...
随机推荐
- Beatcoder#39+#41+#42
HDU5211 思路: 倒着更新每个数的约数,更新完要把自己加上,以及1的情况? //#include <bits/stdc++.h> #include<iostream> # ...
- opencv3.1 压缩并拼图
必须有重叠才能拼,压缩越多,拼接越快 #include <opencv2\opencv.hpp> #include <opencv2\stitching.hpp> using ...
- poj2133(sg函数)
关于sg函数:http://www.cnblogs.com/Knuth/archive/2009/09/05/1561007.html 题目链接:http://poj.org/problem?id=2 ...
- [软件工程基础]PhyLab 功能规格说明书
前言 Sigma 团队想要在 PhyLab 上做的增量改进见需求分析.六个功能中只有题库和图文流程需要对界面进行大的改动,剩下的功能在用户看来仅仅是在原有界面上有内容上的扩充,因此不在功能规格说明书的 ...
- Shortest Path Codeforces - 59E || 洛谷P1811 最短路_NOI导刊2011提高(01)
https://codeforces.com/contest/59/problem/E 原来以为不会..看了题解发现貌似自己其实是会的? 就是拆点最短路..拆成n^2个点,每个点用(i,j)表示,表示 ...
- getpass不起作用
#! /usr/bin/env python# -*- coding:utf-8 -*- # login 模块中登录时输入密码,想用getPass模块实现密码的不回显操作.#如下: import ge ...
- asp.net mvc 中使用 iframe 加载相应的静态html页面进行显示
<iframe src='<%=ResolveUrl("~/Content/HTML_file/Agreement.html")%>' <%@ Page ...
- MVC系列学习(十六)-区域的学习
1.查找控制器的过程 1.1调用其他项目中的控制器 a.先到网站根目录下的bin文件夹下,遍历所有的程序集 b.找到以Controller结尾的类 c.再找出其中继承了Controller的类 d.接 ...
- javascript 转化一个数字数组为function数组(每个function都弹出相应的数字)
javascript 转化一个数字数组为function数组(每个function都弹出相应的数字) var arrNum = [2,3,4,5,6,10,7]; var arrFun = []; f ...
- Java GUI setSize()、setPreferredSize()的区别
setSize().setPreferredSize()都可以设置组件的大小,但二者的使用有所不同. 1.setSize()的使用方式 setSize(int width,int height) se ...