Home > Back-end >  This code is what excuse me I can't run? He couldn't find a mistake, have the ability to b
This code is what excuse me I can't run? He couldn't find a mistake, have the ability to b

Time:11-05

#include

#include

Typedef char Elemtype;

Typedef struct BiTNode
{
char data;
Struct lchild BiTNode * and * rchild;
} BiTNode, * BiTree;

//create a binary tree, agreed the user input data follow the preorder traversal of the
CreateBiTree (BiTree * T)
{
Char c;

The scanf (" % c ", & amp; C);
If (c==' ')
{
* T=NULL;

}
The else
{
* T=(BiTNode *) malloc (sizeof (BiTNode));
(* T) - & gt; data=https://bbs.csdn.net/topics/c;
CreateBiTree (& amp; (* T) - & gt; Lchild);
CreateBiTree (& amp; (* T) - & gt; Rchild);
}
}

//statistics the number of nodes in the binary tree T
Int NodeCount (BiTree T)
{
If (T==NULL)
{
return 0; Nodes is empty,//is the number of 0
}
The else
{
Return NodeCount (T - & gt; Lchild) + NodeCount (T - & gt; Rchild) + 1;//the realization of the recursive process

}
}
Int main ()
{
BiTree T=NULL;

CreateBiTree (& amp; T);
NodeCount (T);

return 0;
}
  • Related