#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Bnode
{
char data;
struct Bnode *lson,*rson;
};
Bnode *Create(char *Infix,char *Suffix, int length)
{
int i;
Bnode *p;
if(length==0)
return NULL;
p=new Bnode;
p->data=Suffix[length-1];
for (i=0;i<length;i++)
if(Infix[i]==Suffix[length-1])
break;
p->lson=Create(Infix,Suffix,i);
p->rson=Create(Infix+i+1,Suffix+i,length-i-1);
return p;
}
void Print(Bnode *b)
{
Bnode *stack[100],*p;
int control[100],top,n;
if(b)
{
cout<<"该二叉树显示结果如下(同一层的结点在同一列上):"<<endl;
top=1;
stack[top]=b;
control[top]=3;
while(top>0)
{
p=stack[top];
n=control[top];
cout<<setw(n)<<p->data<<setfill(' ')<<endl;
top--;
if(p->rson)
{
top++;
stack[top]=p->rson;
control[top]=n+3;
}
if(p->lson)
{
top++;
stack[top]=p->lson;
control[top]=n+3;
}