#include using namespace std; int pwr(int i_num, int p); int f_resume(int r); int count_num(); void f1(); void f2_i(); void f2_ii(); void f3(); void f4(); void f5_i(); void f5_ii(); int i, remainder, ch, d_ch, num, n_count=1; int main() { cin >> num; count_num(); while (true) { ch = (int)num/(pwr(10,count_num()-1)); switch (n_count) { case 1: { f1(); return 0; //break } case 2: { if (ch == 1) { d_ch = num; f2_i(); return 0; //break } else { f2_ii(); if (f_resume(2) == 0) return 0; //break else break; } } case 3: { f3(); if (f_resume(3) == 0) return 0; //break else break; } case 4: { f4(); if (f_resume(4) == 0) return 0; //break else break; } case 5: { if (ch == 1) { d_ch = ((int)num/pwr(10,4)); num -= (d_ch*10*10*10*10); d_ch = (d_ch*10) + ((int)num/pwr(10,3)); f5_i(); if (f_resume(4) == 0) return 0; //break else break; } else { f2_ii(); ch = ((int)num/pwr(10,4)); num = num - (ch*10*10*10*10); ch = (int)num/pwr(10,3); if (ch == 0) { cout << "thousand "; if (f_resume(4)==0) return 0; //break else break; } else break; } } } //switch } //while cout << "\n"; return 0; } int count_num() { for (i = 10, n_count=1; ; i = i * 10, n_count++) { remainder = num/(i); if (remainder == 0) { break; } } return (n_count); } int f_resume(int r) { num -= ((int)num/pwr(10,r-1))*pwr(10,r-1); if (num == 0) return 0; else { n_count--; return 1; } } int pwr(int i_num, int p) { int o_num = 1; for (int j = 1; j <= p; j++) { o_num *= i_num; } return (o_num); } void f1() { switch (ch) { case 0:{cout << "zero "; break;} case 1:{cout << "one "; break;} case 2:{cout << "two "; break;} case 3:{cout << "three "; break;} case 4:{cout << "four "; break;} case 5:{cout << "five "; break;} case 6:{cout << "six "; break;} case 7:{cout << "seven "; break;} case 8:{cout << "eight "; break;} case 9:{cout << "nine "; break;} } } void f2_i() { switch (d_ch) { case 10:{cout << "ten "; break;} case 11:{cout << "eleven "; break;} case 12:{cout << "twelve "; break;} case 13:{cout << "thirteen "; break;} case 14:{cout << "fourteen "; break;} case 15:{cout << "fifteen "; break;} case 16:{cout << "sixteen "; break;} case 17:{cout << "seventeen "; break;} case 18:{cout << "eighteen "; break;} case 19:{cout << "nineteen "; break;} } } void f2_ii() { switch (ch) { case 2:{cout << "twenty "; break;} case 3:{cout << "thirty "; break;} case 4:{cout << "forty "; break;} case 5:{cout << "fifty "; break;} case 6:{cout << "sixty "; break;} case 7:{cout << "seventy "; break;} case 8:{cout << "eighty "; break;} case 9:{cout << "ninty "; break;} } } void f3() { f1(); cout << "hundred "; } void f4() { f1(); cout << "thousand "; } void f5_i() { f2_i(); cout << "thousand "; } void f5_ii() { }