解题思路:先求出输入数字nn的长度count,然后用(nn/i)%10取每一位数字,i为10的(count-1)次方,程序如下,调试编译通过。
#include "stdlib.h"
#include "stdio.h"
void main()
{
int count=0,i,j,k,m,n,nn,num;
printf("please input a numbers:");
scanf("%d",&nn);
n=nn;
for(;n;)
{
n=n/10;
count++;
}
m=count;
for (k=1;k<=count;k++)
{
i=1;
for(j=1;j<m;j++)
i*=10;
num=(nn/i)%10;
m--;
switch(num)
{
case 1:printf("one\t");break;
case 2:printf("two\t");break;
case 3:printf("three\t");break;
case 4:printf("four\t");break;
case 5:printf("five\t");break;
case 6:printf("six\t");break;
case 7:printf("seven\t");break;
case 8:printf("eight\t");break;
case 9:printf("nine\t");break;
case 0:printf("zero\t");break;
}
}
}