c++ 递归思想 阶乘

 1 #include "stdio.h"
 2 #include "iostream"
 3 
 4 long fact(int n);
 5 
 6 int  main()
 7 {
 8     int i;
 9     scanf("%d", &i);
10     printf("%d 的结成结果为: %ld\n",i,fact(i));
11     system("pause");
12     return 0;
13 }
14 
15 long fact(int n)
16 {
17     if (n <= 1)
18         return 1;
19     else
20         return n*fact(n - 1);
21 }

 

posted @ 2019-07-07 11:27  我们都是大好青年  阅读(273)  评论(0编辑  收藏  举报