| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1431 人关注过本帖
标题:#include "LinkBiTree.h"这个为什么总显示错误?
取消只看楼主 加入收藏
哎呦喂撒浪嘿
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-4-27
结帖率:0
收藏
 问题点数:0 回复次数:0 
#include "LinkBiTree.h"这个为什么总显示错误?
#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);
 }
   
2016-04-27 22:24
快速回复:#include "LinkBiTree.h"这个为什么总显示错误?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017415 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved