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> // For cout, cin
# include <string>
# include <map>
# include <cctype> // For toupper
static std::map <char, std::string> const ICAO_alphabet {
{'A', "Alpha" }, {'B', "Bravo" }, {'C', "Charlie" }, {'D', "Delta" },
{'E', "Echo" }, {'F', "Foxtrot" }, {'G', "Golf" }, {'H', "Hotel" },
{'I', "India" }, {'J', "Juliet" }, {'K', "Kilo" }, {'L', "Lima" },
{'M', "Mike" }, {'N', "November"}, {'O', "Oscar" }, {'P', "Papa" },
{'Q', "Quebe" }, {'R', "Romeo" }, {'S', "Sierra" }, {'T', "Tango" },
{'U', "Uniform" }, {'V', "Victor" }, {'W', "Whiskey" }, {'X', "X-ray" },
{'Y', "Yankee" }, {'Z', "Zulu" }
};
int main() {
std::cout << "Enter a letter to find the corresponding International Civil"
<< " Aviation Organization alphabet word\n";
char letter = 0;
if (std::cin >> letter) {
try {
std::cout << ICAO_alphabet.at(std::toupper(letter)) << "\n";
return 0;
}
catch (std::out_of_range) { /* Do nothing */ }
}
std::cout << "Please restart the program and try again.\n";
}
|