#include
#include
using namespace std;
void PrintPostOrder(const string & preorder, const string & inorder, int start1, int start2, int size){
if(size == 1)
{
cout << preorder[start1];
return;
}
if(size == 0)
return;
int i = inorder.find(preorder[start1]);
PrintPostOrder(preorder, inorder, start1+1, start2, i-start2);
PrintPostOrder(preorder, inorder, start1+1+i-start2, start2+1+i-start2, size-i+start2-1);
cout << preorder[start1];
}
int main(void)
{
string preorder, inorder;
while(cin >> preorder >> inorder)
{
PrintPostOrder(preorder, inorder, 0, 0, preorder.size());
cout << endl;
}
}
文章来源于领测软件测试网 https://www.ltesting.net/