zoukankan      html  css  js  c++  java
  • Codeforce 474A

    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.

    Examples
    input
    R
    s;;upimrrfod;pbr
    output
    allyouneedislove

     题解:直接模拟

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <cstdlib>
     7 #include <iomanip>
     8 #include <cmath>
     9 #include <ctime>
    10 #include <map>
    11 #include <set>
    12 using namespace std;
    13 #define lowbit(x) (x&(-x))
    14 #define max(x,y) (x>y?x:y)
    15 #define min(x,y) (x<y?x:y)
    16 #define MAX 100000000000000000
    17 #define MOD 1000000007
    18 #define pi acos(-1.0)
    19 #define ei exp(1)
    20 #define PI 3.141592653589793238462
    21 #define INF 0x3f3f3f3f3f
    22 #define mem(a) (memset(a,0,sizeof(a)))
    23 typedef long long ll;
    24 const int N=205;
    25 const int mod=1e9+7;
    26 int a[12];
    27 int main()
    28 {
    29     string a="qwertyuiopasdfghjkl;zxcvbnm,./";
    30     char b,c[100];
    31     scanf("%c%s",&b,c);
    32     for(int j=0;j<strlen(c);j++)
    33     for(int i=0;i<a.size();i++){
    34         if(a[i]==c[j]){
    35              if(b=='L')
    36                 printf("%c",a[i+1]);
    37              else
    38                 printf("%c",a[i-1]);
    39              break;
    40          }
    41      }
    42     return 0;
    43 }
  • 相关阅读:
    从零开始,使用python快速开发web站点(1)
    实现ListView A~Z快速索引
    红黑树-Python实现
    折扣&折让-看清实质的思考
    【机器学习】初步理解:随机森林
    hdu-4611-Balls Rearrangement
    【经典算法】基本的排序算法:插入排序
    hdu 4620 Fruit Ninja Extreme(状压+dfs剪枝)
    【Java&Android开源库代码剖析】のAndroid-Universal-Image-Loader-part1
    从零开始,使用python快速开发web站点(2)
  • 原文地址:https://www.cnblogs.com/wydxry/p/7259597.html
Copyright © 2011-2022 走看看