//树的数据结构
typedef struct node{
ElemType data; /*数据域*/
struct node *child, *brother; /*孩子与兄弟域 */
}Tree;
//计算树的叶子节点的个数
int Leaves (Tree *root){/*计算以孩子-兄弟表示法存储的森林的叶子数*/
if(root)
if(root->child==NULL) /*若结点无孩子,则该结点必是叶子*/
return(1+Leaves(t->brother));
else
return (Leaves(t->child)+Leaves(t->brother));
}
//树的数据结构
typedef struct node{ElemType data; /*数据域*/struct node *child, *brother; /*孩子与兄弟域 */
}Tree;//计算树的叶子节点的个数
int Leaves (Tree *root){/*计算以孩子-兄弟表示法存储的森林的叶子数*/if(root)if(root->child==NULL) /*若结点无孩子,则该结点必是叶子*/return(1+Leaves(t->brother));elsereturn (Leaves(t->child)+Leaves(t->brother));
}