1 #include <iostream> 2 using namespace std; 3 int abc(int); 4 int fun1(int); 5 int fun1(int a) 6 { 7 cout << "递归函数1" << endl; 8 if (a == 1) 9 { 10 return 1; 11 } 12 return a * fun1(a - 1); 13 } 14 int abc(int a) 15 { 16 cout << "递归函数0" << endl; 17 if (a == 1) 18 { 19 return 1; 20 } 21 22 return a + abc(a - 1); 23 } 24 25 int main() 26 { 27 int b = abc(4); 28 cout << b << endl; 29 int d = fun1(3); 30 cout << "原函数" << endl; 31 cout << d << endl; 32 return 0; 33 }
运行结果:
递归函数0
递归函数0
递归函数0
递归函数0
10
递归函数1
递归函数1
递归函数1
原函数
6
原文:https://www.cnblogs.com/dss-99/p/14071674.html