#include"iostream"
#include"math.h"
#include<bits/stdc++.h>
using namespace std;
//输入先序和中序,输出后序遍历结果
char s1[100]={'a','b','d','e','c'};
char s2[100]={'d','b','e','a','c'};
int posi(char ch){
for(int i = 0;i<strlen(s2);i++){
if(ch==s2[i]){
return i;
}
}
}
int tryit(int l1,int r1,int l2,int r2){
//左子树 s1
int m = posi(s1[l1]);
if(l2<m){
tryit(l1+1,l1-(l2-m),l2,m-1);
}
//右子树
if(r2>m){
tryit(l1-(l2-m)+1,r1,m+1,r2);
}
cout<<s1[l1]<<" ";
}
int main(){
tryit(0,strlen(s1)-1,0,strlen(s2)-1);
}
d e b c a