#include "library.h" const string smalls[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; const string tens[] = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; void say_number(const int N) { if (N < 0) { print("minus "); say_number(- N); } else if (N < 20) print(smalls[N]); else if (N < 100) { print(tens[N / 10]); if (N % 10 != 0) { print(" "); say_number(N % 10); } } else if (N < 1000) { say_number(N / 100); print(" hundred"); if (N % 100 != 0) { print(" and "); say_number(N % 100); } } else if (N < 1000000) { say_number(N / 1000); print(" thousand"); if (N % 1000 != 0) { print(" "); if (N % 1000 < 100) print("and "); say_number(N % 1000); } } else if (N < 1000000000) { say_number(N / 1000000); print(" million"); if (N % 1000000 != 0) { print(" "); if (N % 1000000 < 100) print("and "); say_number(N % 1000000); } } else { say_number(N / 1000000000); print(" billion"); if (N % 1000000000 != 0) { print(" "); if (N % 1000000000 < 100) print("and "); say_number(N % 1000000000); } } } void test_it() { print("Number? "); const int num = read_int(); say_number(num); new_line(); test_it(); } void main() { test_it(); }