题解 | #WERTYU#
WERTYU
https://www.nowcoder.com/practice/0f318e6fffe3490cb700e16b65a93b1b
#include<cstdio> #include<map> #include<string> using namespace std; int main() { map<char, char> myMap = { {'W', 'Q'}, {'E', 'W'}, {'R', 'E'}, {'T', 'R'}, {'Y', 'T'}, {'U', 'Y'}, {'I', 'U'}, {'O', 'I'}, {'P', 'O'}, {'[', 'P'}, {']', '['}, {'S', 'A'}, {'D', 'S'}, {'F', 'D'}, {'G', 'F'}, {'H', 'G'}, {'J', 'H'}, {'K', 'J'}, {'L', 'K'}, {';', 'L'}, {'X', 'Z'}, {'C', 'X'}, {'V', 'C'}, {'B', 'V'}, {'N', 'B'}, {'M', 'N'}, {',', 'M'}, {'.', ','}, {'/', '.'}, {' ', ' '}, {'0', '9'}, {'9', '8'}, {'8', '7'}, {'7', '6'}, {'6', '5'}, {'5', '4'}, {'4', '3'}, {'3', '2'}, {'2', '1'}, {'=', '-'}, {'[', 'P'},{']', '['},{'\'',';'} }; char arr[100]; char ch = ' '; myMap[ch] = ch; fgets(arr, 100, stdin); string s = arr; s.pop_back(); for (int i = 0 ; i < s.size() ; ++i) { s[i] = myMap[s[i]]; } for (int i = 0 ; i < s.size() ; ++i) { printf("%c", s[i]); } }