求助!!!
查看原帖
求助!!!
395826
taoyuhan楼主2022/1/13 20:11
#include<bits/stdc++.h>
using namespace std;

struct node {
	char data;
	node *lchild;
	node *rchild;
};
node *root;
string s,t; 
int _find(char c) {
	for (int i=0;i<s.size();i++) 
		if (s[i]==c) 
			return i;
	return -1;
}
node build(int len,int l,int r) {
	if (len==0) return NULL;
	char w=t[len-1];
	int v=_find(w);
	node T=new node;
	T->data=w;
	T->lchild=build(len-1,l,v);
	T->rchild=build(len-1,v+1,r);
	return T;
}
void TREE(node *T) {
	if (T) {
		cout<<T->data;
		TREE(T->lchild);
		TREE(T->rchild);
	}
}
int main() {
	root=new node;
	cin>>s>>t;
	root=build(t.size(),0,s.size());
	TREE(root);
	return 0;
} 

编译出错了

2022/1/13 20:11
加载中...