p126-6 -_-
#include <stdlib.h>
#define ElemType int
typedef struct BiTNode {
ElemType data;
struct BiTNode *lchild, *rchild;
} BiTNode, *BiTree;
BiTree PreInCreat(ElemType A[], ElemType B[], int l1, int h1, int l2, int h2) {
BiTree root = (BiTree) malloc(sizeof(BiTNode));
int i, llen, rlen;
root->data = A[l1];
for (i = l2; A[l1] != B[i]; i++);
llen = i - l2;
rlen = h2 - i;
if (llen) root->lchild = PreInCreat(A, B, l1 + 1, l1 + llen, l2, l2 + llen - 1);
else root->lchild = NULL;
if (rlen) root->rchild = PreInCreat(A, B, h1 - rlen + 1, h1, h2 - rlen + 1, h2);
else root->rchild = NULL;
return root;
}