输入一个不大于10的9次方的正整数,从高位开始逐位分割并输出各位数字。 例如,输入 12345 ,输出 1 2 3 4 5

#include<stdio.h>
int main()
{
 long int n;
 int b[10],i=0,j;
 scanf("%ld",&n);
 while(1)
 {
 if(n>0)
  {
  b[i]=n%10;
  n=n/10;
  i++;
  } 
  else
  break; 
 }
 for(j=i-1;j>=0;j--)
 printf("%d ",b[j]);
 return 0; 
}

猜你喜欢

转载自blog.csdn.net/qq_42387291/article/details/80672498