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
|
# include <string>
# include <map>
# include <sstream>
int main (int, char**) {
std::map <std::string, char> const morseCode
{{".-" , 'A'}, {"-...", 'B'}, {"-.-.", 'C'}, {"-.." , 'D'},
{"." , 'E'}, {"..-.", 'F'}, {"--." , 'G'}, {"....", 'H'},
{".." , 'I'}, {".---", 'J'}, {"-.-" , 'K'}, {".-..", 'L'},
{"--" , 'M'}, {"-." , 'N'}, {"---" , 'O'}, {".--.", 'P'},
{"--.-", 'Q'}, {".-." , 'R'}, {"..." , 'S'}, {"-" , 'T'},
{"..-" , 'U'}, {"...-", 'V'}, {".--" , 'W'}, {"-..-", 'X'},
{"-.--", 'Y'}, {"--..", 'Z'}, {"/" , ' '}};
using namespace std::string_literals;
std::string entireCode = ""s + ".... . .-.. .-.. --- / -.. .- .. .-.. -.-- / ."
+ "--. .-. --- --. .-. .- -- -- . .-. / --. --- --- -.. / .-.. ..- -.-. -.- "
+ "/ --- -. / - .... . / -.-. .... .- .-.. .-.. . -. --. . ... / - --- -.. "
+ ".- -.--";
std::istringstream stream(entireCode);
for (std::string token; stream >> token; ) {
std::cout << morseCode.at(token);
}
std::cout << "\n";
}
|