#include<stdio.h>
#include<stdlib.h>
typedef struct Bitnode{
char data;
struct Bitnode *lchild,*rchild;
}Bitnode,*Bitree;
void creatBitree(Bitree &t){
char ch;
scanf("%c",&ch);\
if(ch=='#')t=NULL;
else{
t=(Bitnode*)malloc(sizeof(Bitnode));
t->data=ch;
creatBitree(t->lchild);
creatBitree(t->rchild);
}
}
void zhongxu(Bitree &t){
if(t){
zhongxu(t->lchild);
printf("%c",t->data);
zhongxu(t->rchild);
}
}
void houxu(Bitree &t){
if(t){
houxu(t->lchild);
houxu(t->rchild);
printf("%c",t->data);
}
}
int judge(Bitree t){
if(!(t))return 0;
else{
if(judge(t->lchild)==judge(t->rchild))return 1;
else return 0;
}
}
void main(){
Bitree T;
printf("先序输入:\n");
creatBitree(T);
printf("中序输出: \n");
zhongxu(T);
printf("\n");
printf("后序输出: \n");
houxu(T);
printf("\n");
printf("是否为正则二叉树\n");
if(judge(T))
printf("yes\n");
else
printf("no\n");
}