c语言 数字转换成单词

来源:百度知道 编辑:UC知道 时间:2024/06/05 19:32:44
额。。有个作业要求输入从1到9999数字的英文。。。
怎样才能让电脑读出英文呢。。。不要太复杂的方法哦。。
对不起..要求是输入一个数..然后读出相应的英文...比如
enter the number: 3256
three thousand two hundred and fifty-six..

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

/*
* 重复的部分可以查表
* 自己编,就好些,不复杂
*/

char* num_list0[20] = {
"","one","two","three","four",
"five","six","seven","eight","nine",
"ten","eleven","twelve","thirteen","fourteen",
"fifteen","sixteen","seventeen","eighteen","nineteen"
};

char* num_list1[10] = {
"","ten","twenty","thirty","fourty","fifty",
"sixty","seventy","eighty","ninety"
};

// 查表找英文,数字转换为可以读的单词
// “有数字” 表示 “有非零的数字”
void haveIt(int nI, char *num_str) {
unsigned len;
char aA[5];
char str[100];
itoa(