Home > Back-end >  Write a binary tree program don't know where is wrong, have a big help to have a look
Write a binary tree program don't know where is wrong, have a big help to have a look

Time:11-01

# include
# include
# define NULL 0
Typedef struct Node {char data; Struct Node * Lchild; Struct Node * Rchild; } Bitnode, * Bittree;
Int leafcount=0;
Void the Create (bt) Bittree *
{char ch;
The scanf (" % c ", & amp; Ch);
If (ch==') * bt=NULL;
The else {
* bt=(Bittree) malloc (sizeof (Bitnode)); Bt (*) - & gt; data=https://bbs.csdn.net/topics/ch;
Create (& amp; (bt) (* - & gt; Lchild));
Create (& amp; (bt) (* - & gt; Rchild));
}
}
Int the leaf (Bittree bt)
{
If (bt!!!!=NULL)
{
The leaf (bt - & gt; Lchild);
The leaf (bt - & gt; Rchild); If (bt - & gt; Lchild==NULL& & Bt - & gt; Leafcount++ Rchild==NULL);
}
Return leafcount;
}
Int main ()
{
Bittree p;
Create (& amp; P);
Printf (" % d \ n ", the leaf (p));
return 0;
}

CodePudding user response:

Remove the function of the asterisk
  • Related