// UVa 10222 - Decode the Mad man
#include <string>
#include <iostream>
#include <map>
using namespace std;
const string keyboard = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
int main() {
map<char, int> idx;
for (int i = 0; i < keyboard.length(); i++)
idx[keyboard[i]] = i;
string line;
while (getline(cin, line)) {
for (int i = 0; i < line.length(); i++) {
if ('A' <= line[i] && line[i] <= 'Z')
line[i] = line[i] - 'A' + 'a';
int new_idx = idx[line[i]] - 2;
if (0 <= new_idx && new_idx < keyboard.length())
cout << keyboard[new_idx];
else
cout << line[i];
}
cout << endl;
}
return 0;
}
Monday, May 4, 2015
UVa 10222 - Decode the Mad man
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment