fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void spell(int n, string* const &a)
  6. {
  7. if (n == 0)
  8. return;
  9. spell(n / 10, a);
  10. cout << a[n % 10];
  11. }
  12.  
  13. int main()
  14. {
  15. int n;
  16. string a[10]{"zero ", "one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine "};
  17. do
  18. {
  19. if ((!(cin >> n)) || (n < 0))
  20. break;
  21. spell(n, a);
  22. }
  23. while (true);
  24. return 0;
  25. }
Success #stdin #stdout 0s 4544KB
stdin
123
stdout
one two three