-->
当前位置:首页 > 题库 > 正文内容

CODE_COMPLETION:Binary tree - 12. Number of branch nodes

Luz3年前 (2021-06-06)题库15184

Please write a function to find the number of branch nodes (non terminal nodes) of binary tree.
####Function prototype
```c
int BinTreeNumBranch(const TNODE *root);
```
Note: ` root 'is the root pointer of the binary tree, and the function value is the number of non terminal nodes of the binary tree.
Declare the function in the header file * bintree. H * and write the function in the program file * bintree. C *.
*BinTree.h*
```c
......
int BinTreeNumBranch(const TNODE *root);
......
```
*BinTree.c*
```
......
/*The code you submit will be embedded here*/
```
####Adjudication procedure
*main.c*
```c
#include


#include "BinTree.h"
int main()
{
TNODE *r;
BinTreeCreate(&r);
BinTreeInput(&r);
printf("%d\n", BinTreeNumBranch(r));
BinTreeDestroy(&r);
return 0;
}
```
![ Title. JPG] (~ / d1f8b532-136b-4ec2-b86f-db91d936e735. JPG)
####Input sample
```in
EIBJ##H###DF#A##G#C##
```
####Output sample
```out
six
```





answer:If there is no answer, please comment

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。