#include <stdio.h>
#include <stdlib.h>
char a[][10]={ "zero","one","two","three","four","five","six","seven","eight","nine"};
char b[][10]={"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
char c[][10]={"ten","eleven","twelve","thirteen","thirteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
void qian(int x)
{
int i;
for(i=0;a[x][i]!='\0';i++)
{
printf("%c",a[x][i]);
}
printf(" hundred");
}
void bai(int y)
{
int i;
for(i=0;b[y-2][i]!='\0';i++)
{
printf("%c",b[y-2][i]);
}
}
void shi(int z)
{
int i;
for(i=0;a[z][i]!='\0';i++)
{
printf("%c",a[z][i]);
}
}
void shi2(int y)
{
int i;
for(i=0;c[y][i]!='\0';i++)
{
printf("%c",c[y][i]);
}
}
int main()
{
int n;
scanf("%d",&n);
int x,y,z;
x=n/100;
y=n/10%10;
z=n%10;
if(x!=0&&y!=0)
{
qian(x);
printf(" and ");//三位数
bai(y);
printf("-");
shi(z);
}
if(x!=0&&y==0&&z!=0)
{
qian(x);
printf(" and ");
shi(z);
}
if(x!=0&&y==0&&z==0)
{
qian(x);
}
if(x==0&&y!=0&&z==0)
{
bai(y);
}
if(x==0&&y!=1&&z!=0)
{
bai(y);//两位数且不为1
printf("-");
shi(z);
}
if(x==0&&y==1)
{
shi2(z);
}//以1开头的两位数
if(x==0&&y==0)
{
shi(z);//一位数
}
return 0;
}
考虑清楚不同的情况,三位数两位数一位数,还有比较特殊的就是百位为0的三位数