#include "library.h" const string Small[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; const string tynumber[] = { "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; void say(const int n) { if (n < 0) { cout << "minus "; say(- n); } else if (n < 20) cout << Small[n]; else if (n%10 == 0 && n<100) cout << tynumber[n/10 - 2]; else if (n >= 20 && n < 100) { const int first = n /10 * 10, second = n % 10; say(first); cout << "-"; say(second); } else if (n < 1000) { const int first = n / 100; const int second = n % 100; say(first); cout << " hundred"; if (second > 0) { cout << " and "; say(second); } } else if (n < 1000000) { const int first = n / 1000; const int second = n % 1000; say(first); cout << " thousand"; if (second > 0) { cout << " "; say(second); } } else if (n < 1000000000) { const int first = n / 1000000; const int second = n % 1000000; say(first); cout << " million"; if (second > 0) { cout << " "; say(second); } } else { const int first = n / 1000000000; const int second = n % 1000000000; say(first); cout << " billion"; if (second > 0) { cout << " "; say(second); } } } void onestep(const int N) { cout << " else if (n == " << N << ")\n"; cout << " cout << \""; say(N); cout << "\";\n"; if (N < 10000) onestep(N+1); } void main() { cout << "#include \"library.h\"\n\n"; cout << "void main()\n"; cout << "{ if (N == 0)\n"; cout << " cout << \"zero\";\n"; onestep(1); cout << "}\n"; }