二叉树还原

include <bits/stdc++.h>

using namespace std;

void fun(string a, string b) {
int t = b.find(a[0]);
if (t != 0)
fun(a.substr(1, t), b.substr(0, t));
if (b.size() > t + 1)
fun(a.substr(t + 1), b.substr(t + 1));
cout << a[0];
}
int main() {
string m, n;
while (cin >> m >> n) {
fun(m, n);
cout << endl;
}
return 0;
}

posted @ 2024-04-19 21:57  niubuniu  阅读(1)  评论(0编辑  收藏  举报