#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct Bnode
{
char data;
Bnode *lch;
Bnode *rch;
};
typedef Bnode* Btree;
void CreatBtree(Btree &T)
{
char ch;
if(!(cin>>ch))exit(0);
if(ch=='.') T=NULL;
else
{
T=(Btree)malloc(sizeof(Bnode));
if(!T) exit(0);
T->data=ch;
CreatBtree(T->lch);
CreatBtree(T->rch);
}
}
void InOrderTraverse(Btree T)
{
if(T==NULL) return ;
InOrderTraverse(T->lch);
cout<<T->data;
InOrderTraverse(T->rch);
}
void PostOrderTraverse(Btree T)
{
if(T==NULL) return ;
PostOrderTraverse(T->lch);
PostOrderTraverse(T->rch);
cout<<T->data;
}
int main()//以已知扩展前序序列为例
{
for(;;)
{
Btree root;
CreatBtree(root);
InOrderTraverse(root);
cout<<endl;
PostOrderTraverse(root);
cout<<endl;
}
}