题目大意

题目链接

给出中序后序求先序, 递归求即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
using namespace std;
void solve(string s1, string s2) {
if (s1.size()) {
int num = s1.find(s2[s2.size() - 1]);
cout << s1[num];
solve(s1.substr(0, num), s2.substr(0, num));
solve(s1.substr(num + 1), s2.substr(num, s1.size() - num - 1));
}

}
string s1, s2;
int main() {
cin >> s1 >> s2;
solve(s1, s2);
cout << '\n';
}
1
恰似你一低头的温柔,娇弱水莲花不胜寒风的娇羞, 我的心为你悸动不休。  --mingfuyan