#include <stdio.h>
int main()
{
int a,b,c,d;
while(1)
{
printf("请输入一个三位整数\n");
scanf("%d",&a);
b=a%10;
c=a/10%10;
d=a/100;
switch(d)
{
case 1:printf("one hundred ");break;
case 2:printf("two hundred ");break;
case 3:printf("three hundred ");break;
case 4:printf("four hundred ");break;
case 5:printf("five hundred ");break;
case 6:printf("six hundred ");break;
case 7:printf("seven hundred ");break;
case 8:printf("eight hundred ");break;
case 9:printf("nine hundred ");break;
}
if(b==0&&c==0)
printf(" ");
else
printf("and ");
if(c!=1)
{
switch(c)
{
case 2:printf("twenty ");break;
case 3:printf("thirty ");break;
case 4:printf("forty ");break;
case 5:printf("fifty ");break;
case 6:printf("sixty ");break;
case 7:printf("seventy ");break;
case 8:printf("eighty ");break;
case 9:printf("ninety ");break;
case 0:printf(" ");break;
}
switch(b)
{
case 1:printf("one\n");break;
case 2:printf("two\n");break;
case 3:printf("three\n");break;
case 4:printf("four\n");break;
case 5:printf("five\n");break;
case 6:printf("six\n");break;
case 7:printf("seven\n");break;
case 8:printf("eight\n");break;
case 9:printf("nine\n");break;
case 0:printf(" \n");break;
}
}
if(c==1)
{
switch(b)
{
case 1:printf("eleven\n");break;
case 2:printf("twelve\n");break;
case 3:printf("thirteen\n");break;
case 4:printf("fourteen\n");break;
case 5:printf("fifteen\n");break;
case 6:printf("sixteen\n");break;
case 7:printf("seventeen\n");break;
case 8:printf("eighteen\n");break;
case 9:printf("nineteen\n");break;
case 0:printf("ten\n");break;
}
}
}
return 0;
}
P53 第36题 数字转化成英语输出