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

CODE_COMPLETION:Binary tree - 10. Finding the number of nodes

Luz3年前 (2021-05-10)题库451
Please write a function to find the number of nodes in the binary tree.
####Function prototype
```c
int BinTreeNumNode(const TNODE *root);
```
Note: ` root 'is the root pointer of the binary tree, and the function value is the node number 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 BinTreeNumNode(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", BinTreeNumNode(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
ten
```







answer:If there is no answer, please comment

发表评论

访客

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