在你输入12345后,系统在等待你的继续输入, 12345还在int的范围内,因此它被存储在a[0]中,系统这个时候再等待你的a[1],a[2]...的值. 不是程序运行不出来, 而是程序一直在正确的运行,等待你的输入. 你还没有输入完,程序没法继续向下执行.
另外,你的程序这样子写,一定通不过的. 对问题的切入点搞错了, 程序怎么都不会正确了.
好久不动键盘了, 试着写一个,能达到程序输出要求. 没有细考虑算法问题.
程序代码:#include <stdio.h>
int main()
{
int number,temp[5],i,j,k,a,b,c;
if((i=(scanf("%d",&number)))!=1)
{printf("输入有误! \n");
return 0;}
else {
temp[0]=number/10000;
a=number%10000;
temp[1]=a/1000;
b=a%1000;
temp[2]=b/100;
c=b%100;
temp[3]=c/10;
temp[4]=number%10;
for(i=0;i<5;i++){
if(temp[i]>0)
{printf("%d\n",5-i);
goto s;}
}
s: for(j=i;j<5;j++){
printf("%d",temp[j]);
if(j!=4)printf(" ");
else printf("\n");
}
for(k=4;k>=0;k--){
if(temp[k]!=0)printf("%d",temp[k]);
}
return 0;
}
}









