C语言:打印出一个整数的每一位

#include<stdio.h>
#include<stdlib.h>

void ergodic(int x)
{
 if (x < 10)
 {
  printf("%d", x);
 }
 else
 {
  int n = x % 10;
  printf("%d ", n);
  ergodic( x / 10);

 }
}
int main()
{
 int x = 2048;

 ergodic(x); 
 system("pause");
 return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_43647265/article/details/86494903
今日推荐