#include <stdio.h>
const char* num1[] =
{
"", "one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen",
"fifteen","sixteen","seventeen","eighteen","nineteen"//引入个位字符库
};
const char* num10[] =
{
"","","twenty","thirty","forty","fifty","sisty","seventy",
"eighty","ninety"//引入十位字符库
};
int main()
{
int input = 0;
printf("请输入要转换的数字\n");
scanf_s("%d", &input);//数字输入
int a = input % 10;
int test1 = input / 10;
int b = test1 % 10;
int c = input / 100;
int test2 = input % 100;//数字提取
if (b <= 2 && input <= 20)//1~20处理
{
printf("%s", num1[input]);
}
else if (input < 100 && input>20)//两位数处理
{
printf("%s %s", num10[b], num1[a]);
}
else if (input >= 100 && input < 1000 )//三位数处理
{
if (test2 > 20)
{
printf("%s hundred and %s %s", num1[c], num10[b], num1[a]);
}
else if (test2 <= 20)
{
printf("%s hundred and %s", num1[c], num1[test2]);
}
}
else
{
printf("输入错误");
}
return 0;
}