二叉树的建立学习笔记

来源:互联网 发布:小程序 video.js 编辑:程序博客网 时间:2024/06/06 18:22

http://blog.sina.com.cn/s/blog_a19e8c1b01016m2v.html



#include <stdio.h>

#define ElemType char

//节点声明,数据域、左孩子指针、右孩子指针

typedef struct BiTNode{

    char data;

    struct BiTNode *lchild,*rchild;

}BiTNode,*BiTree;

//先序建立二叉树

BiTree CreateBiTree(){

    char ch;

    BiTree T;

    scanf("%c",&ch);

    if(ch=='#')T=NULL;

    else{

        (BiTree)malloc(sizeof(BiTNode));

        T->data ch;

        T->lchild CreateBiTree();

        T->rchild CreateBiTree();

    }

    return T;//返回根节点

}




0 0
原创粉丝点击