Q:输入一个数,输出英文表达。
#include"stdio.h" char data_1[19][10]={"0ne","two","three","four","five","six","seven","eight","nine","ten" ,"eleven","twelve","thirteen","forteen","fifteen","sixteen","seventeen", "eighteen","ninteen"}; char data_2[8][9]={"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninty"}; void translation_C(long b) { //翻译十位与个位 long c; if(b<=19) printf("%s ",data_1[b-1]); else { c=b/10; printf("%s ",data_2[c-2]); c=b%10; if(c!=0) printf("%s ",data_1[c-1]); } } void translation_B(long a) { //翻译百位 long b; b=a/100; if(b!=0) { translation_C(b); printf("hundred "); } b=a%100; if(b!=0) translation_C(b); } void translation_A(long N) { //翻译千位 long a; if(N==0) { printf("Zero "); return ; } a=N/1000; if(a!=0) { translation_B(a); printf("thousand "); } a=N%1000; if(a!=0) translation_B(a); } int main() { long N; printf("input a longeger from 0~999999 "); scanf("%ld",&N); translation_A(N); return 0; }