[]运行没有关问题,但上交就是错的。求大神解释。

[求助]运行没问题,但上交就是错的。求大神解释。。。。。。
Description
给出一个正整数(positive integer)(不超过10位),从高位开始逐位分割并输出。

Input
测试数据有多行,每行是一个正整数 n ,不含前导零。

Output
对每个测试输出一行结果:分割后的整数序列,各位数之间用一个空格隔开。
温馨提示:最后一个数字后面没有空格哦,否则PE哦。

Sample Input
654321
1

Sample Output
6 5 4 3 2 1
1

#include <stdio.h>
int main (void) 
{
int n;
int t;
int a[10];
int i;
while(scanf("%d",&n)!=EOF)
{
t = n/10;
i = 0;
while (t > 0) {
a[i] = n%10;
i++;
//printf("%2d",n%10);
n = n/10; 
t = n/10;
}
a[i] = n;
for (;i >= 0;i--)
{
printf("%d ",a[i]);
}
getchar();
printf("\n");
}

return 0;
}

------解决方案--------------------
#include <stdio.h>
int main (void) 
{


int n;
int t;
int a[10];
int i;
while(scanf("%d",&n)!=EOF)
{
t = n/10;
i = 0;
while (t > 0) {
a[i] = n%10;
i++;
//printf("%2d",n%10);
n = n/10; 
t = n/10;
}
a[i] = n;
for (;i >= 0;i--)
{
if(i!=0)
printf("%d ",a[i]);
else{
printf("%d",a[i]);
}
}
getchar();
printf("\n");
}
system("pause");
return 0;
}

发现你输出的最后一个数字后面有空格,这里不合题意,所以只是改了下你的输出,加了个if 判断
------解决方案--------------------
#include<stdio.h>
int main()
{
    int a[10],n,i;
    while(~scanf("%d",&n))
    {
        i=0;
        while(n)
        {
            a[i++] = n%10;
            n /=10;
        }
        for(i -=1;i>=0;--i)
            printf("%d%s",a[i],i ? " " : "\n");
    }
    return 0;
}

你试下这个代码
------解决方案--------------------
#include<stdio.h> 
int main() 
{     
int a[10],n,i;    
while(~scanf("%d",&n))     
{         
if(!n)
{
printf("0\n");
continue;
}
i=0;         
while(n)         
{             
a[i++] = n%10;             
n /=10;         
}         
for(i -=1;i>=0;--i)             
printf("%d%s",a[i],i ? " " : "\n");     
}     
return 0; 
}