#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
char s1[1000],s2[1000],s3[1000],s4[1000];
typedef struct node
{
char data;
struct node *lchild,*rchild;
}Binode,*Bitree;
void CreateBitree(Bitree &t)
{
char x;
scanf("%c",&x);
if(x=='#') t=NULL;
else
{
t=(Binode *)malloc(sizeof(Binode));
t->data=x;
CreateBitree(t->lchild);
CreateBitree(t->rchild);
}
}
void Preorder(Bitree t)
{
int n=0;
s1[n++]=t->data;
Preorder(t->lchild);
Preorder(t->rchild);
}
void Inorder(Bitree t)
{
int n=0;
Inorder(t->lchild);
s2[n++]=t->data;
Inorder(t->rchild);
}
void Posorder(Bitree t)
{
int n=0;
Posorder(t->lchild);
Posorder(t->rchild);
s3[n++]=t->data;
}
int main()
{
int i=0;
Bitree t;
CreateBitree(t);
Preorder(t);
Inorder(t);
Posorder(t);
//eqeorder(t);
if(strcmp(s1,s3))
printf("二叉树的先序序列和后序序列相同\n");
else if(strcmp(s2,s3))
printf("二叉树的中序序列和后序序列相同\n");
else if(strcmp(s1,s2))
printf("二叉树的中序序列和后序序列相同\n");
//else if(strcmp(s2,s4))
//printf("二叉树的中序序列和层次遍历序列相同\n");
return 0;
}