//数据结构:先序、中序、后序遍历二叉树。输入数据:abd##eg###c#f#h##
#include <stdio.h>
#include <stdlib.h>
//定义数据类型
typedef char Elemtype;
typedef struct tnode
{
Elemtype data;
struct tnode *Lchild; //左孩子
struct tnode *Rchild; //右孩子
}*BiTree;
//创建以t为根的二叉树
void create(BiTree *t)
{
char ch;
scanf("%c",&ch);
if(ch=='#')
{
*t=NULL;
return;
}
else
{
*t=(BiTree)malloc(sizeof(struct tnode));
(*t)->data=ch;
create(&((*t)->Lchild));
create(&((*t)->Rchild));
}
}
//先序遍历二叉树
void PreorderTraverse(BiTree root) /*先序遍历以root为根的二叉树*/
{ if(root!=NULL)
{ printf("%c ",root->data); /*访