2020-10-05
已知二叉树的中序和后序求前序
题目
https://www.luogu.com.cn/problem/P1030
参考于
https://www.luogu.com.cn/problem/solution/P1030
代码
#include
using namespace std;
typedef long long ll;
int dfs(string a,string b)
{
if(a.size()==0)
return 0;
cout<<b[b.size()-1];
int k=a.find(b[b.size()-1]);
dfs(a.substr(0,k),b.substr(0,k));
dfs(a.substr(k+1),b.substr(k,a.size()-k-1));
}
int main()
{
string a,b;
cin>>a>>b;
dfs(a,b);
return 0;
}