Posted on 2007-07-02 00:41
停留的风 阅读(1041)
评论(1) 编辑 收藏
#include <stdio.h>
int main(void)
{
int number,temp,length=3;
printf("Enter an int three unit number!\n");
scanf("%i",&number);
int sum[3];
while(number!=0)
{
temp=number%10;
sum[length-1]=temp;
length--;
number=number/10;
}
for(int i=0;i<3;i++)
{
switch(sum[i])
{
case 0:
printf("zero ");
break;
case 1:
printf("one ");
break;
case 2:
printf("two ");
break;
case 3:
printf("three ");
break;
case 4:
printf("four ");
case 5:
printf("five ");
break;
case 6:
printf("six ");
break;
case 7:
printf("seven ");
break;
case 8:
printf("enght ");
break;
case 9:
printf("nine ");
break;
default:
printf("Unknown char not a number!");
break;
}
}
printf("\n");
return 0;
}
测试结果: