基于上一篇我发的二叉树模板函数,添加一个子节点个数的函数,
int SonCountHelp(const BinTreeNode* r) const;//子节点的个数
int SonCount() const;
数据结构--二叉树构造模板_m0_53252742的博客-CSDN博客
inline int BinaryTree::SonCount() const { return SonCountHelp(root); }
templateinline int BinaryTree ::SonCountHelp(const BinTreeNode * r) const { if (r == NULL) return 0; else if (r->leftChild == NULL || r->rightChild == NULL) return SonCountHelp(r->leftChild) + SonCountHelp(r->rightChild) + 1; else if (r->leftChild != NULL) SonCountHelp(r->leftChild); else if (r->rightChild != NULL) SonCountHelp(r->rightChild); }



