#include "library.h" string Small[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; string tens[] = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; void say(const int N) { if (N < 20) cout << Small[N]; else if (N < 100) { cout << tens[N / 10] << " "; if (N % 10 != 0) say(N % 10); } // up to this point, it is guaranteed to work for every number < 100 else if (N < 1000) { const int first = N / 100; const int second = N % 100; say(first); cout << " hundred"; if (second != 0) { cout << " "; say(second); } } // up to this point, it is guaranteed to work for every number < 1000 else if (N < 1000000) { const int first = N / 1000; const int second = N % 1000; say(first); cout << " thousand"; if (second != 0) { cout << " "; say(second); } } // up to this point, it is guaranteed to work for every number < 1000000 } void main() { const int x = read_int(); say(x); cout << "\n"; main(); }