http://codeforces.com/problemset/problem/474/A

A. Keyboard
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

Print a line that contains the original message.

Sample test(s)
input
R
s;;upimrrfod;pbr
output
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的更多相关文章

  1. Codeforces Round #271 (Div. 2)题解【ABCDEF】

    Codeforces Round #271 (Div. 2) A - Keyboard 题意 给你一个字符串,问你这个字符串在键盘的位置往左边挪一位,或者往右边挪一位字符,这个字符串是什么样子 题解 ...

  2. Codeforces Round #271 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/474 A题:Keyboard 模拟水题. 代码例如以下: #include <iostream> #include ...

  3. Codeforces Round #271 (Div. 2)

    A. Keyboard 题意:一个人打字,可能会左偏一位,可能会右偏一位,给出一串字符,求它本来的串 和紫书的破损的键盘一样 #include<iostream> #include< ...

  4. Codeforces Round #271 (Div. 2) F. Ant colony (RMQ or 线段树)

    题目链接:http://codeforces.com/contest/474/problem/F 题意简而言之就是问你区间l到r之间有多少个数能整除区间内除了这个数的其他的数,然后区间长度减去数的个数 ...

  5. Codeforces Round #271 (Div. 2) D. Flowers (递推)

    题目链接:http://codeforces.com/problemset/problem/474/D 用RW组成字符串,要求w的个数要k个连续出现,R任意,问字符串长度为[a, b]时,字符串的种类 ...

  6. Codeforces Round #271 (Div. 2) E题 Pillars(线段树维护DP)

    题目地址:http://codeforces.com/contest/474/problem/E 第一次遇到这样的用线段树来维护DP的题目.ASC中也遇到过,当时也非常自然的想到了线段树维护DP,可是 ...

  7. Codeforces Round #271 (Div. 2) F题 Ant colony(线段树)

    题目地址:http://codeforces.com/contest/474/problem/F 由题意可知,最后能够留下来的一定是区间最小gcd. 那就转化成了该区间内与区间最小gcd数相等的个数. ...

  8. 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 ...

  9. Codeforces Round #271 (Div. 2) F ,E, D, C, B, A

    前言:最近被线段树+简单递推DP虐的体无完肤!真是弱! A:简单题,照着模拟就可以,题目还特意说不用处理边界 B:二分查找即可,用lower_lound()函数很好用 #include<stri ...

随机推荐

  1. Swift3.0 轮播图

    使用三个UIButton实现无限轮播:https://github.com/LXfeiYu/LXCarouselImages.git 喜欢的朋友给个星!!! 功能: 1.可以选择开启和关闭定时器 2. ...

  2. 萌新笔记之堆(heap)

    前言(萌新感想): 以前用STL的queue啊stack啊priority_queue啊,一直很想懂原理,现在终于课上到了priority_queue,还有就是下周期中考,哈哈,所以写几篇blog总结 ...

  3. lightoj 1027【数学概率】

    #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N=1e2+10; int ma ...

  4. 适合新手看的超详细CentOS Linux 7 安装Tomcat8过程

    非常详细的安装Tomcat8的步骤,适合新手学习.废话不多说,直接干! 前提条件 1. 已有可直接连接的CentOS7系统 2. CentOS7系统已安装Java JDK 8 下载Tomcat8 下载 ...

  5. UGUI DOTween渐隐渐现

    Tween tweenAlpha; tweenAlpha = DOTween.To(() => MaskSpr.fillAmount, x => MaskSpr.fillAmount = ...

  6. mongodb c# 序列化时 , Id引起的问题

    1.  c# 序列化时,如果没有指名_id , 如果class,struct有MemberName为 Id ,_id , 则自动识别为Id . 如果此时,这个"Id"是只读属性,就 ...

  7. Codevs 1282 约瑟夫问题

    1282 约瑟夫问题  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master 题解       题目描述 Description 有编号从1到N的N个小朋友在玩一种 ...

  8. Python 学习 Part1

    1. 斐波那契数序列 >>> a,b=0,1 >>> a 0 >>> b 1 >>> while b<10: print( ...

  9. Java语言和虚拟机规范下载

  10. CSS 两边是线 中间是文字的效果

    刚开始做的时候 想了一下 这个是怎么做出来的,后来在网上看到有个类似的效果,研究一下 <!DOCTYPE html> <html lang="en"> &l ...