输入一个正整数,用递归的方式输出该数的各位数字,要求正序、逆序都要输出。
嗯这个只是训练递归用的一个小程序。

1 #include <stdio.h>
2 void fun(int n);
3 void fun2(int n);
4 int main(int argc, char *argv[])
5 {
6 int n;
7 scanf("%d",&n);
8 fun(n);
9 printf("\n");
10 fun2(n);
11 return 0;
12 }
13 void fun(int n)
14 {
15 int t;
16 if(n==0)
17 {
18 return ;
19 }
20 else
21 {
22 t=n%10;
23 fun(n/10);
24 printf("%d ",t);
25 }
26 }
27 void fun2(int n)
28 {
29 int t;
30 if(n==0)
31 {
32 return ;
33 }
34 else
35 {
36 t=n%10;
37
38 printf("%d ",t);
39 fun2(n/10);
40 }
41 }
来源:https://www.cnblogs.com/huashanqingzhu/p/4476916.html
