这个程序有什么问题吗!!各位大神救济一下啊~~
#include "LinkBiTree.h"这个为什么总显示错误?急!#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef char DataType;
#define MAXSIZE 100
#include "LinkBiTree.h"
typedef struct Node
{
DataType data;
struct Node*lchild;
struct Node*rchild;
}*BiTree,BiNode;
void CreateBiTree(BiTree *T,char str[])
{
DataType ch;
scanf("%c",&ch);
if(ch=='#')
*T=NULL;
else
{
*T=(BiTree)malloc(sizeof(BitNode));
if(!(*T))
exit(-1);
(*T)->data=ch;
CreateBiTree(&((*T)->lchild));
CreateBiTree(&((*T)->rchild));
}
}
void LeavePrint(BiTree T)
{
BiTree queue[MAXSIZE];
BitNode *p;
int front,rear;
front=rear=-1;
rear++;
queue[rear]=T;
while(front!=rear)
{
front=(front+1)%MAXSIZE;
p=queue[front];
printf("%c"p->data);
if(p->lchild!=NULL)
{
rear=(rear+1)%MAXSIZE;
queue[rear]=p->lchild;
}
if(p->rchild!=NULL)
{
rear=(rear+1)%MAXSIZE;
queue[rear]=p->rchild;
}
}
}
void TreePrintf(BiTree T,int level)
{
int i;
if(T==NULL)
return;
TreePrintf(T->rchild,level+1);
for(i=0;i<level;i++)
printf(" ");
printf("%c\n",T->data);
TreePrintf(T->lchild,level+1);
}
int LeafNum(BiTree T)
{
if(!T)
return 0;
else if(!T->lchild&&!T->rchild)
return 1;
else
return LeafNum(T->lchild)+LeafNum(T->rchild);
}
int NotLeafCount(BiTree T)
{
if(!T)
return 0;
else if(!T->lchild&&!T->rchild)
return 0;
else
return NotLeafCount(T->lchild)+NotLeafCount(T->rchild)+1
}
int BitTreeDepth(BiTree T)
{
if(T==NULL)
return 0;
return BiTreeDepth(T->lchild)>BiTreeDepth(T->rchild);
1+BiTreeDepth(T->lchild):1+BiTreeDepth(T->rchild);
}
int main()
{
BiTree T,root;
int num,depth;
printf("根据括号嵌套(a(b(c,d),e(f(,g),h(i))))建立二叉树:\n");
CreateBiTree(&root,"(a(b(c,d),e(f(,g),h(i))))");
num=LeafNum(root);
printf("叶子节点个数:%2d\n",num);
num=NotLeafCount(root);
printf("非叶子节点个数:%2d\n",num);
depth=BitTreeDepth(root);
printf("二叉树的深度:%2d\n",depth);
DestroyBitTree(&T);
DestroyBitTree(&root);
}