题目链接:http://codeforces.com/contest/474/problem/A
大致题意:就是键盘上的三行字符。每行十个,如今给你一个串,告诉你它的偏移方式(左偏一位或者右偏一位),让你输出原串。
解题思路:非常easy。数据给的不大,那就直接暴力了,直接把三十个字符开个string或数组存一下。能够开三个,也能够开一个。可是我建议还是开一个好。看得更清楚。
直接扫一遍度入的串,要是左偏,就输出它的后面一个字符。否则。输出它的左边一个字符就可以。
AC代码:
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define INF 0x7fffffff
string a = "qwertyuiop";
string b = "asdfghjkl;";
string c = "zxcvbnm,./";
int main()
{
#ifdef sxk
freopen("in.txt","r",stdin);
#endif
string n, s;
while(cin>>n>>s)
{
int len = s.size();
if(n[0] == 'R'){
for(int i=0; i<len; i++){
for(int j=0; j<10; j++){
if(s[i] == a[j]){
printf("%c",a[j-1]);
break;
}
}
for(int j=0; j<10; j++){
if(s[i] == b[j]){
printf("%c",b[j-1]);
break;
}
}
for(int j=0; j<10; j++){
if(s[i] == c[j]){
printf("%c",c[j-1]);
break;
}
}
}
}
else{
for(int i=0; i<len; i++){
for(int j=0; j<10; j++){
if(s[i] == a[j]){
printf("%c",a[j+1]);
break;
}
}
for(int j=0; j<10; j++){
if(s[i] == b[j]){
printf("%c",b[j+1]);
break;
}
}
for(int j=0; j<10; j++){
if(s[i] == c[j]){
printf("%c",c[j+1]);
break;
}
}
}
}
printf("\n");
}
return 0;
}