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. 牛客 - 17968 - xor序列 - 线性基

    https://ac.nowcoder.com/acm/problem/17968 下面是错误的做法,因为题目要求必须使用x,而y在check的时候不一定用到等价于x的线性基来构成. 正确的做法是直接 ...

  2. 读取MySQL数据表字段信息

    TP5句式 $fieldinfo = Db::query('SHOW FULL COLUMNS FROM '.$table);//查出数据表所有字段信息Field 字段Comment 字段注释

  3. 洛谷P3292 [SCOI2016]幸运数字(倍增+线性基)

    传送门 不知道线性基是什么东西的可以看看蒟蒻的总结 第一眼:这不会是个倍增LCA暴力合并线性基吧…… 打了一发……A了? 所以这真的是个暴力倍增LCA合并线性基么…… ps:据某大佬说其实可以离线之后 ...

  4. Oracle GoldenGate对接 Oracle 11g和Kafka

    本文主要是向读者介绍如何通过 ogg 为 oracle 数据库的变更操作实时同步到大数据产品 kafka 上. 开始介绍前,先为读者介绍一下环境背景 机器ip 和其对应的服务 192.168.88.1 ...

  5. Maven - settings.xml里的offline节点的作用

    场景 某天我在本地修改了某个子项目的代码,并进行了打包:mvn clean install -DskipTests,接着我运行父项目却发现自己刚刚的改动并没有生效,或者说,我刚刚打包好的子项目变回了打 ...

  6. 自定义的cell上面有图片时,如果产生了重用,图片可能会错乱问题

    当被重用的cell将要显示时,会调用这个方法,这个方法最大的用武之地是当你自定义的cell上面有图片时,如果产生了重用,图片可能会错乱(当图片来自异步下载时及其明显),这时我们可以重写这个方法把内容抹 ...

  7. nginx,tomcat,apache三者分别用来做什么,有何区别

    1. Nginx和tomcat的区别 nginx常用做静态内容服务和代理服务器,直接外来请求转发给后面的应用服务器(tomcat,Django等),tomcat更多用来做一个应用容器,让java we ...

  8. 牛客寒假6-B.煤气灶

    链接:https://ac.nowcoder.com/acm/contest/332/B 题意: 小j开始打工,准备赚钱买煤气灶. 第一天,小j的工资为n元,之后每天他的工资都比前一天多d元. 已知煤 ...

  9. rsync服务的安装与配置

    rsync 服务的安装配置与客户端的同步操作   1. 使用xinetd服务运行rsync服务: 服务器端: 1.关闭selinux,设置iptables开放xinetd的873端口 2. yum - ...

  10. kafka系列一:单节点伪分布式集群搭建

    Kafka集群搭建分为单节点的伪分布式集群和多节点的分布式集群两种,首先来看一下单节点伪分布式集群安装.单节点伪分布式集群是指集群由一台ZooKeeper服务器和一台Kafka broker服务器组成 ...