1 struct BiTree 2 { 3 struct BiTree *lchild; 4 struct BiTree *rchild; 5 }; 6 7 int Node(struct BiTree *T) 8 { 9 if(T == NULL) 10 return 0; 11 return 1+Node(T->lchild)+Node(T->rchild); 12 } 13 14 int Leaf(struct BiTree *T) 15 { 16 if(T==NULL) 17 return 0; 18 if(T->lchild == NULL && T->rchild == NULL) 19 return 1; 20 return Leaf(T->lchild)+Leaf(T->rchild); 21 }
时间: 2024-10-12 10:39:30