题意:给定一个键盘,然后一行字母,和一个字符,代表把那一行字母在键盘上左移还是右移一位。

析:没什么好说的,直接暴力就好。

代码如下:

#include<bits/stdc++.h>

using namespace std;
typedef long long LL;
char s1[] = "qwertyuiop";
char s2[] = "asdfghjkl;";
char s3[] = "zxcvbnm,./";
char s[105]; int main(){
char ch;
scanf("%c", &ch);
scanf("%s", s);
int n = strlen(s); int n1 = strlen(s1);
int n2 = strlen(s2);
int n3 = strlen(s3);
for(int i = 0; i < n; ++i){
bool ok = false;
// cout << s[i];
for(int j = 0; j < n1; ++j)
if(s1[j] == s[i]){ cout << (ch == 'R' ? s1[j-1] : s1[j+1]); ok = true; break; }
if(ok) continue;
for(int j = 0; j < n2; ++j)
if(s2[j] == s[i]){ cout << (ch == 'R' ? s2[j-1] : s2[j+1]); ok = true; break; }
if(ok) continue;
for(int j = 0; j < n3; ++j)
if(s3[j] == s[i]){ cout << (ch == 'R' ? s3[j-1] : s3[j+1]); ok = true; break; }
} return 0;
}

CodeForces 474A Keyboard (水题)的更多相关文章

  1. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  2. CodeForces 705A Hulk (水题)

    题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...

  3. Codeforces 474A Keyboard (水

    题目链接:点击打开链接 键盘移位了,问输出相应的字母 #include <cstdio> #include <cstring> char a[105]; char b[3][1 ...

  4. CodeForces 705B (训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2) ...

  5. codeforces hungry sequence 水题

    题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...

  6. codeforces 377A. Puzzles 水题

    A. Puzzles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/33 ...

  7. CodeForces 474B Worms (水题,二分)

    题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc+ ...

  8. CodeForces - 682B 题意水题

    CodeForces - 682B Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — ...

  9. CodeForces 709A Juicer (水题, 模拟)

    题意:给定 n 个桔子的大小,一个杯子的容积,一个最大限度,挨着挤桔子汁,如果大小大于限度,扔掉,如果不杯子满了倒掉,问你要倒掉多少杯. 析:直接按要求模拟就好,满了就清空杯子. 代码如下: #pra ...

随机推荐

  1. 第四章 istio快速入门(快速安装)

    4.1 环境介绍 K8s 1.9 以上版本. 4.2 快速部署Istio 下载:  https://github.com/istio/istio/releases/,  下载 1.1.0-snapsh ...

  2. laravel-ide-helper 遇到There are no commands defined问题怎么解决

    laravel门面类的代码提示方案: https://github.com/barryvdh/laravel-ide-helper 按照步骤安装 1.composer require barryvdh ...

  3. Java toString()方法

    JDK API java.lang 的Object类中的toString()方法 toString public String toString() 返回该对象的字符串表示.通常,toString 方 ...

  4. C++ primer plus

    给cout指针,默认打印指针地址,但如果指针的类型的char*,将打印指向的字符串,如果要显示的是字符串的地址,将指针强制转换为另一种类型 char* animal cout << ani ...

  5. MySQL多项模糊查询

    最近有个需求,就是要根据搜索框里面的关键字,找到符合条件的数据. 如果是单个条件的话,其实就是一个普通的select语句. 但是需求是这个关键字,要在id,desc,step等多个字段模糊查找. 然后 ...

  6. 「小程序JAVA实战」小程序头像图片上传(上)(43)

    转自:https://idig8.com/2018/09/08/xiaochengxujavashizhanxiaochengxutouxiangtupianshangchuan40/ 在微信小程序中 ...

  7. Linux监控和安全运维 1.9 zabbix增加客户端监控

    1.在客户端安装 zabbix20与服务器相对应. yum install zabbix20-agent 2.修改配置文件 vim /etc/zabbix_agentd.conf Server=127 ...

  8. 常用的API接口

    主页 :http://api.36wu.com/ GetWeather(实时气象)API 服务地址:http://api.36wu.com/Weather/GetWeather?city=?;如:ht ...

  9. (halcon) derivate_vector_field

    derivate_vector_field: Convolve a vector field with derivatives of the Gaussian 用高斯导数卷积向量场 derivate_ ...

  10. sortingOrder,sortingLayer

    sortingOrder 是sortingLayer内的分级 sortingLayer是抽象的分层,用于决定2D物体绘制的先后顺序. 2D物体分两类:sprite和UI. sprite虽是2D,却可以 ...