题目所述基本内容
A New Alphabet has been developed for Internet communications. While the glyphs of the new alphabet don’t necessarily improve communications in any meaningful way, they certainly make us feel cooler.
You are tasked with creating a translation program to speed up the switch to our more elite New Alphabet by automatically translating ASCII plaintext symbols to our new symbol set.
The new alphabet is a one-to-many translation (one character of the English alphabet translates to anywhere between 1 and 6 other characters), with each character translation as follows:
Original | New | English Description | Original | New | English Description |
a | @ | at symbol | n | []\[] | brackets, backslash, brackets |
b | 8 | digit eight | o | 0 | digit zero |
c | ( | open parenthesis | p | |D | bar, capital D |
d | |) | bar, close parenthesis | q | (,) | parenthesis, comma, parenthesis |
e | 3 | digit three | r | |Z | bar, capital Z |
f | # | number sign (hash) | s | $ | dollar sign |
g | 6 | digit six | t | '][' | quote, brackets, quote |
h | [-] | bracket, hyphen, bracket | u | |_| | bar, underscore, bar |
i | | | bar | v | \/ | backslash, forward slash |
j | _| | underscore, bar | w | \/\/ | four slashes |
k | |< | bar, less than | x | }{ | curly braces |
l | 1 | digit one | y | `/ | backtick, forward slash |
m | []\/[] | brackets, slashes, brackets | z | 2 | digit two |
For instance, translating the string “Hello World!” would result in:
[-]3110 \/\/0|Z1|)!
Note that uppercase and lowercase letters are both converted, and any other characters remain the same (the exclamation point and space in this example).
输入输出样例
Input
Input contains one line of text, terminated by a newline. The text may contain any characters in the ASCII range 32–126 (space through tilde), as well as 9 (tab). Only characters listed in the above table (A–Z, a–z) should be translated; any non-alphabet characters should be printed (and not modified). Input has at most 10000 characters.
Output
Output the input text with each letter (lowercase and uppercase) translated into its New Alphabet counterpart.
代码
#include<iostream>
#include<string>
using namespace std;
int main() {
string a;
getline(cin, a);
for (int i = 0; i < a.length(); i++) {
if (a[i] == 'a' || a[i] == 'A') cout << "@";
else if (a[i] == 'b' || a[i] == 'B') cout << "8";
else if (a[i] == 'c' || a[i] == 'C') cout << "(";
else if (a[i] == 'd' || a[i] == 'D') cout << "|)";
else if (a[i] == 'e' || a[i] == 'E') cout << "3";
else if (a[i] == 'f' || a[i] == 'F') cout << "#";
else if (a[i] == 'g' || a[i] == 'G') cout << "6";
else if (a[i] == 'h' || a[i] == 'H') cout << "[-]";
else if (a[i] == 'i' || a[i] == 'I') cout << "|";
else if (a[i] == 'j' || a[i] == 'J') cout << "_|";
else if (a[i] == 'k' || a[i] == 'K') cout << "|<";
else if (a[i] == 'l' || a[i] == 'L') cout << "1";
else if (a[i] == 'm' || a[i] == 'M') cout << "[]\\/[]";
else if (a[i] == 'n' || a[i] == 'N') cout << "[]\\[]";
else if (a[i] == 'o' || a[i] == 'O') cout << "0";
else if (a[i] == 'p' || a[i] == 'P') cout << "|D";
else if (a[i] == 'q' || a[i] == 'Q') cout << "(,)";
else if (a[i] == 'r' || a[i] == 'R') cout << "|Z";
else if (a[i] == 's' || a[i] == 'S') cout << "$";
else if (a[i] == 't' || a[i] == 'T') cout << "']['";
else if (a[i] == 'u' || a[i] == 'U') cout << "|_|";
else if (a[i] == 'v' || a[i] == 'V') cout << "\\/";
else if (a[i] == 'w' || a[i] == 'W') cout << "\\/\\/";
else if (a[i] == 'x' || a[i] == 'X') cout << "}{";
else if (a[i] == 'y' || a[i] == 'Y') cout << "`/";
else if (a[i] == 'z' || a[i] == 'Z') cout << "2";
else cout << a[i];
}
}