文章
37
粉丝
98
获赞
4
访问
24.1k
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct node {
char ch;
struct node* left, * right;
};
string forStr,cenStr;
int len, cnt=0;
struct node* createTree(int low, int high, struct node* T) {
if (low > high) {
return NULL;//结束
}
//在中序遍历中查找对应根结点
for (int i = low; i <= high; i++) {
if (cenStr[i] == forStr[cnt]) {
cnt++;
//记录下下标
//创建结点
T = (struct node*)malloc(sizeof(struct node));
T->ch = cenStr[i];
&nb...
登录后发布评论
暂无评论,来抢沙发