#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
char data;
struct Node *lchild;
struct Node *rchild;
}Bitree;
void CreateBiTree(Bitree *t)
{
char s;
if(s=='#')
t=NULL;
else
{
t=(Bitree *)malloc(sizeof(Node));
t->data=s;
CreateBiTree(t->lchild);
CreateBiTree(t->rchild);
}
}
void Output(Bitree *t)
{
if(t!=NULL)
{
printf("%c ",t->data);
Output(t->lchild);
Output(t->rchild);
}
}
int main()
{
Bitree *root;
printf("请以先序遍历依次为二叉树赋值:");
CreateBiTree(root);
printf("以先序遍历输出二叉树:");
Output(root);
printf("\n");
return 0;
#include<stdlib.h>
typedef struct Node
{
char data;
struct Node *lchild;
struct Node *rchild;
}Bitree;
void CreateBiTree(Bitree *t)
{
char s;
if(s=='#')
t=NULL;
else
{
t=(Bitree *)malloc(sizeof(Node));
t->data=s;
CreateBiTree(t->lchild);
CreateBiTree(t->rchild);
}
}
void Output(Bitree *t)
{
if(t!=NULL)
{
printf("%c ",t->data);
Output(t->lchild);
Output(t->rchild);
}
}
int main()
{
Bitree *root;
printf("请以先序遍历依次为二叉树赋值:");
CreateBiTree(root);
printf("以先序遍历输出二叉树:");
Output(root);
printf("\n");
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/bc49e2b09a2a677a553397f05c74f94d.jpeg)