第九周

include<stdio.h>

include<stdlib.h>

//树的定义
typedef char DataType;
typedef struct Node {
DataType data;
struct Node *lchild;
struct Node rchild;
} BiNode,
Tree;

//创建树的二叉链表
void CreateTree(Tree *tt)
{
char ch;
ch = getchar();
if(ch=='.') tt=NULL;
else
{
tt= (BiNode )malloc(sizeof(BiNode));
(
tt)->data=ch;
CreateTree(&((
tt)->lchild)); //生成左子树
CreateTree(&((
tt)->rchild)); //生成右子树
}
}

//输出二叉树的元素
void Print(Tree tt)
{
if(tt==NULL)
return;
else
{
printf("%c ", tt->data);
Print(tt->lchild);
Print(tt->rchild);
}

}

posted @ 2020-06-10 11:47  lin1235  阅读(95)  评论(0)    收藏  举报