題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1163
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <iostream> #include <cctype> #include <vector> #include <string>
using namespace std;
string words = "`1234567890-=qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./";
int main(){ string text; while(getline(cin, text)){ vector<char> ans; int size = text.length(); for(int i=0; i<size; ++i){ if(text[i] == ' ') ans.push_back(' '); else{ int index = words.find(text[i]); ans.push_back(words[index-2]); } } size = ans.size(); for(int i=0; i<size; ++i){ cout << ans[i]; } cout << '\n'; } return 0; }
|