main( )
{
long int x;
int a,b,c,d,e,num;
scanf("%ld",&x);
if (x>9999)
num=5;
else if (x>999)
num=4;
else if (x>99)
num=3;
else if (x>9)
num=2;
else num=1;
printf("x=%ld
num=%d\n",x,num);
a=x/10000;
b=(x-a*10000)/1000;
c=(x-a*10000-b*1000)/100;
d=(x-a*10000-b*1000-c*100)/10;
e=x-a*10000-b*1000-c*100-d*10;
switch(num)
{
case 5: printf("there are 5,%d %d %d %d %d\n",e,d,c,b,a);
printf("there are 5,%d %d %d %d %d\n",a,b,c,d,e);
break;
case 4: printf("there are 4,%d%d%d%d",e,d,c,b);
break;
case 3: printf("there are 3,%d%d%d",e,d,c);
break;
case 2: printf("there are 2,%d%d",e,d);
break;
case 1: printf("there are 1,%d",e);
}
}
这是我编写的5位的,意思和你的相同,供你参考!