遞歸函數頗有意思,要講一下。好比要計算n!咱們就這樣定義:ios
#include <iostream>
這個遞歸函數在二叉樹的遍歷中使用的最多,並且很方便:函數
template <class T>spa
void preorder(T *root){遞歸
if(root!==NULL){io
cout<<root->data<<"-->"class
preorder(root->leftleaf);stream
preorder(root->rightleaf);二叉樹
}遍歷
}co