#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
char data;
struct node *lchild;
struct node *rchild;
char ch;
}btnode,*bitree;
void createbitree(bitree *bt)//创建一棵二叉树
{
char ch;
ch=getchar();
if(ch=='.')
*bt=NULL;
else
{
*bt=(bitree)malloc(sizeof(btnode));
(*bt)->data=ch;
createbitree(&((*bt)->lchild));
createbitree(&((*bt)->rchild));
}
}
void preorder(bitree root)//先序遍历
{
if(root!=NULL)
{
printf(&root->data);
preorder(root->lchild);
preorder(root->rchild);
}
}
void inorder(bitree root)//中序遍历
{
if(root!=NULL)
{
inorder(root->lchild);
printf(&root->data);
inorder(root->rchild);
}