递归函数颇有意思,要讲一下。好比要计算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