标题:二叉树中这样创建不对吗
只看楼主
仙君进栈
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-12-8
结帖率:0
已结贴  问题点数:20 回复次数:1 
二叉树中这样创建不对吗
#ifndef     g1_h#define        g1_h#include<stdio.h>#include<stdlib.h>typedef struct node{    char e;    struct node *lchild,*rchild;}BiTNode,*BiTree;void InitTree(BiTree tree){    tree=NULL;}void DestroyTree(BiTree tree){    if(tree){        if(tree->lchild)            DestroyTree(tree->lchild);        if(tree->rchild)            DestroyTree(tree->rchild);        free(tree);        tree=NULL;    }}BiTree CreateTree(BiTree tree){    char ch;    fflush(stdin);    scanf("%c",&ch);    if(ch=='#')        tree=NULL;    else{        if(!(tree=(BiTNode*)malloc(sizeof(BiTNode))))            exit (0);        tree->e=ch;        CreateTree(tree->lchild);        CreateTree(tree->rchild);    }    return tree;}void Empty(BiTree tree){    if(!tree)        printf("the tree is empty:\n");    printf("the tree is not empty:\n");}#endif#include"g1.h"#include<stdlib.h>#include<stdio.h>void main(){    BiTree tree;    tree=(BiTNode*)malloc(sizeof(BiTNode));    InitTree(tree);    printf("input the root of tree:\n");    CreateTree(tree);}
搜索更多相关主题的帖子: include 二叉树 
2016-12-28 14:54
Valenciax
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:11
帖 子:337
专家分:2462
注 册:2016-5-15
得分:20 
发到C语言论坛吧
https://bbs.bccn.net/forum-5-1.html
2016-12-28 20:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-473039-1-1.html




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

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