提交时间:2023-08-23 14:50:09
运行 ID: 99659
#include<bits/stdc++.h> using namespace std; void dfs(string mid,string end){ int len = end.size(); if (len == 0){ return ; } char root = end[len - 1]; cout<<root; int pos = mid.find(root); dfs(mid.substr(0,pos),end.substr(0,pos)); dfs(mid.substr(pos + 1,len - pos - 1),end.substr(pos,len - pos - 1)); } int main(){ string mid,end; cin>>end>>mid; dfs(mid,end); return 0; }