我是地图新手,地图似乎是解决这个问题的好主意。我想提供一个输入并通过地图运行该输入,然后输出相关的值。有可能按照这些思路做点什么吗?
#include <iostream>
#include <map>
#include <string>
int main()
{
std::string word;
word ="1110001010101000100000001110111010111000101011100010100011101011101000111010111";
//std::cout << "Please, enter your phrase: ";
//std::getline (std::cin,word);
// char inputstring[100];
//while(std::cin.good()){
std::map <std::string, char> morse_char;
morse_char["000"] = ' ';
morse_char["10111"] = 'a';
morse_char["111010101"] = 'b';
morse_char["11101011101"] = 'c';
morse_char["1110101"] = 'd';
morse_char["1"] = 'e';
morse_char["101011101"] = 'f';
morse_char["111011101"] = 'g';
morse_char["1010101"] = 'h';
morse_char["101"] = 'i';
morse_char["1011101110111"] = 'j';
morse_char["111010111"] = 'k';
morse_char["101110101"] = 'l';
morse_char["1110111"] = 'm';
morse_char["11101"] = 'n';
morse_char["11101110111"] = 'o';
morse_char["10111011101"] = 'p';
morse_char["1110111010111"] = 'q';
morse_char["1011101"] = 'r';
morse_char["10101"] = 's';
morse_char["111"] = 't';
morse_char["1010111"] = 'u';
morse_char["101010111"] = 'v';
morse_char["1110111"] = 'w';
morse_char["11101010111"] = 'x';
morse_char["1110101110111"] = 'y';
morse_char["11101110101"] = 'z';
//}
std::cout << word << std::endl;
return 0;
}