递归追溯退出

 1 #include <iostream>
 2 
 3 using namespace std;
 4 
 5 void countdown(int n);
 6 
 7 extern int main01()
 8 {
 9     countdown(4);
10     return 0;
11 }
12 
13 void countdown(int n)
14 {
15     cout << "Couting down ... " << n << " \t(n at" << &n << ")" << endl;
16     if(n > 0)
17     {
18         countdown( n - 1 );
19     }
20     cout << n << " : Kaboom!" << " \t\t(n at" << &n << ")\n";
21 }
递归追溯退出

 

posted @ 2016-06-03 14:47  岑小良  阅读(152)  评论(0编辑  收藏  举报