Spoken Numbers by kou

*s[]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"},*u[]={"\n"," thousand"," million"," billion"};a,m;p(n,t){n?printf(a%2+(t?" %s":" %s hundred"),s[n-1+t%2*18]),a=0:0;}t(n,l){if(m=n/1e3)t(m,l+1),a=2;p(n/100%10,0);p((n%=100)/20?p(n/10,1),n%=10:n,2);l*a||printf(u[l]);}main(){for(;a=!!gets(&m);t(atoi(),0));}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page