#include #include "vector.h" #include "CPstring.h" // file: convert.cc // author Dietolf Ramm; date: 11/10/96 // change number to English using recursion. string Conv(int n, const Vector & table) // precondiont: n a non-negative integer // postcondition: returns string of number in word form { if (n < 10) { return table[n]; } return Conv(n/10, table)+table[n%10]; } int main() { Vector table(10); table[0] = "Zero "; table[1] = "One "; table[2] = "Two "; table[3] = "Three "; table[4] = "Four "; table[5] = "Five "; table[6] = "Six "; table[7] = "Seven "; table[8] = "Eight "; table[9] = "Nine "; int base, n; cout << "Enter positive integer (negative number to quit): "; cin >> n; while ( n >= 0) { cout << n << " reads: " << Conv(n, table) << endl; cout << "Enter positive integer (negative number to quit): "; cin >> n; } return 0; } Sample output: convert Enter positive integer (negative number to quit): 123 123 reads: One Two Three Enter positive integer (negative number to quit): 321 321 reads: Three Two One Enter positive integer (negative number to quit): 87654321 87654321 reads: Eight Seven Six Five Four Three Two One Enter positive integer (negative number to quit): 0 0 reads: Zero Enter positive integer (negative number to quit): -1