# 输出数字

（1）判断它是一个几位数
（2）按顺序输出其各位数字，用逗号隔开
（3）逆序输出其各位数字，用逗号隔开

``````3
56439
467
9345``````

``````Case 1:
5
5,6,4,3,9
9,3,4,6,5
Case 2:
3
4,6,7
7,6,4
Case 3:
4
9,3,4,5
5,4,3,9``````

``````#include<stdio.h>
int j;
int wei(int n)
{
int i=10;
/*while(n>9)//普通循环
{
n=n/i;
i=i*10;
j++;
}
return j;*/
j++;//递归
if(n<=9)
return j;
else
return wei(n/10);
}
int main()
{
int n,num,i,w,m[6],q,k;
scanf("%d",&n);
for(i=0;i<n;i++)
{
k=10;
j=0;
scanf("%d",&num);
w=wei(num);
m[0]=num%10;
for(q=1;q<w;q++)
{
k=k*10;
m[q]=(num%k-m[q-1])/(k/10);
}
printf("Case %d:\n",i+1);
printf("%d\n",w);
for(q=w-1;q>0;q--)
printf("%d,",m[q]);
printf("%d",m[0]);
printf("\n");
for(q=0;q<w-1;q++)
printf("%d,",m[q]);
printf("%d",m[q]);
printf("\n");
}
return 0;
}``````

``````
#include <iostream>
#include<memory.h>
using namespace std;
int main()
{
int num,arr[5],count,number;
cin>>num;
for(int casenum=1; casenum<=num; casenum++)
{
cin>>number;
memset(arr,0,sizeof(arr));
count=0;
while(number!=0)
{
arr[count++]=number%10;
number=number/10;
}
cout<<"Case "<<casenum<<":"<<endl;
cout<<count<<endl;
for(int i=count-1; i>=0; i--)
{
cout<<arr[i];
if(i!=0)
cout<<",";
}
cout<<endl;
for(int i=0; i<count; i++)
{
cout<<arr[i];
if(i!=count-1)
cout<<",";
}
cout<<endl;
}

}
``````