#include<stdio.h>
typedef struct BTnode
{
char data;
struct BTnode *lchild;
struct BTnode *rchild;
}BTnode;
//先序创建二叉树
BTnode * precreate()
{
char str;
BTnode *bt = NULL;
scanf("%c",&str);
if(str == '#')
return NULL;
if(isupper(str))//节点只能为大写字母
{
bt = (BTnode *) malloc (sizeof(BTnode));
bt->data = str;
bt->lchild = precreate();
bt->rchild = precreate();
}
return bt;
}
int main()
{
BTnode *bt = create();
return 0;
}
创建二叉树 c语言
最新推荐文章于 2024-10-01 20:11:33 发布