提交时间:2023-08-23 15:57:31

运行 ID: 99700

#include <iostream> #include <string> using namespace std; void dfs(string zhong, string hou) { int len = zhong.size(); if (len == 0) return ; char gen = hou[len-1]; cout << gen; int pos = zhong.find(gen); dfs(zhong.substr(0, pos), hou.substr(0, pos)); dfs(zhong.substr(pos + 1, len - pos - 1), hou.substr(pos, len - pos - 1)); } int main() { string zhong, hou; cin >>hou >> zhong; dfs(zhong, hou); return 0; }