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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iostream>
#include <map>
int main()
{
std::map<int, std::string> dictionary;
dictionary.emplace(1, "one");
dictionary.emplace(2, "two");
dictionary.emplace(3, "three");
dictionary.emplace(4, "four");
dictionary.emplace(5, "five");
dictionary.emplace(6, "six");
dictionary.emplace(7, "seven");
dictionary.emplace(8, "eight");
dictionary.emplace(9, "nine");
dictionary.emplace(10, "ten");
dictionary.emplace(11, "eleven");
dictionary.emplace(12, "twelve");
dictionary.emplace(13, "thirteen");
dictionary.emplace(14, "fourteen");
dictionary.emplace(15, "fifteen");
dictionary.emplace(16, "sixteen");
dictionary.emplace(17, "seventeen");
dictionary.emplace(18, "eighteen");
dictionary.emplace(19, "nineteen");
dictionary.emplace(20, "twenty");
dictionary.emplace(30, "thirty");
dictionary.emplace(40, "forty");
dictionary.emplace(50, "fifty");
dictionary.emplace(60, "sixty");
dictionary.emplace(70, "seventy");
dictionary.emplace(80, "eighty");
dictionary.emplace(90, "ninety");
std::cout << "Enter a number: ";
int number;
std::cin >> number;
if (number < 20)
{
std::cout << dictionary[number];
}
else if (number < 100)
{
std::cout << dictionary[number / 10 * 10] << ' ' << dictionary[number % 10];
}
return 0;
}
|