今天來解YKL14(UVA10222):Decode the Mad man
這題在講鍵盤上的位移
k->h
[->o
r->w
d->a
y->r
t->e
I->y
[->o
o->u
全部都是往左位移兩格
且要為小寫
#include <iostream>
#include <string>
using namespace std;
int main(){
string keyboard = "`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
string str;
while(getline(cin,str)){
for(int i=0;i<=str.size();i++){
if(str[i] >= 'A' && str[i] <= 'Z')str[i] = str[i] + ('a' - 'A');
if(str[i]==' '){
cout << " ";
continue;
}
for(int j=0;j<keyboard.size();j++){
if(str[i]==keyboard[j]){
cout << keyboard[j-2];
}
}
}
cout << endl;
}
return 0;
}