欢迎使用本站,预祝练习时长两年半的选手们到成功! [本模块信息来自tem/def/head]

1339:求后序遍历

时间:2024-05-05 12:50 作者:admin 点击:
#include iostreamusing namespace std;string a,b;void f(string xx,string zx){if(xx.size()==0) return ;char root=xx[0];int rootid=zx.find(root);string lzx=zx.substr(0,rootid);string rzx=zx.substr(rootid+1);string lxx=xx.substr(1,rootid);strin
#include <iostream>
using namespace std;
string a,b;
void f(string xx,string zx){
	if(xx.size()==0) return ;
	char root=xx[0];
	int rootid=zx.find(root);
	string lzx=zx.substr(0,rootid);
	string rzx=zx.substr(rootid+1);
	string lxx=xx.substr(1,rootid);
	string rxx=xx.substr(rootid+1);
	f(lxx,lzx);
	f(rxx,rzx);
	cout<<root;
}
int main(){
	cin>>a>>b;
	f(a,b);
	return 0;
}


(责任编辑:admin)
    顶一下
    (0)
    0%
    踩一下
    (0)
    0%