2009-d-二-3

//天勤p150原题

BTNode *CreateBT(char pre[],char in[],int l1,int r1,int l2, int r2)
{
    BTNode *s;
    int i;
    if(l1>r1) return NULL;
    s=(BTNode*)malloc(sizeof(BTNode));
    s->lchild=s->rchild=NULL;
    for(i=l2,i<r2;++i)
        if(in[i]==pre[l1])
            break;
    s->data=in[i];
    s->lchild=CreateBT(pre,in,l1+1,l1+i-l2,l2,i-1);
    s->rchild=CreateBT(pre,in,l1+i-l2+1,r1,i+1,r2);
    return s;
}