#include <stdio.h>
#include <malloc.h>
int main (void)
{
int a, b, c, h, i, t, l;//i是位数
char f;
do
{
i = 0;
printf("请输入一个数:");
scanf("%d", &a);
c = a;
for (;a != 0; i++)
{
b = a/10;
a = b;
}
int * p = (int *)malloc(i*sizeof(int));
for (h = 0;h < i;h++)
{
l = c%10;
if (l)
p[h]=l;
c /= 10;
}
printf("您输入的数的每位数分别为:\n");
for (h = i - 1; h>=0;h--)
{
printf("%5d",p[h]);
}
printf("\n");
printf ("您输入的数的位数:%d\n", i);
printf ("还想继续吗?是请输入字母 Y ,否则结束:");
scanf(" %c", &f);// %c前必须加空格
}
while (f == 'Y' || f == 'y');
return 0;
}
温馨提示:答案为网友推荐,仅供参考