蒟蒻求助,书上写的是 C 风格字符串,不得不说十分简便,string 有没有什么简便的方法?是不是必须加一个变量记录字符串的开始位置
struct Bnode
{
char data;
struct Bnode *lchild, *rchild;
};
Bnode *pre_mid_createtree(char *pre, char *mid, int len)
{
if (len == 0)
return NULL;
char ch = pre[0];
int index = 0;
while (mid[index] != ch)
index++;
Bnode *t = new Bnode;
t->data = ch;
t->lchild = pre_mid_createtree(pre + 1, mid, index);
t->rchild = pre_mid_createtree(pre + index + 1, mid + index + 1, len - index - 1);
}