首页 > 其他 > 详细

CodeForces 474A Keyboard (水题)

时间:2016-07-12 22:58:31      阅读:433      评论:0      收藏:0      [点我收藏+]

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

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

代码如下:

#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 (水题)

原文:http://www.cnblogs.com/dwtfukgv/p/5665137.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!