递归追溯退出
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 }