代码:
#include <iostream>
#include <string>
using namespace std;
string middle, front;
void cut (int ms, int me, int fs, int fe);//先写main是个好(?)习惯
int main () {
cin >> middle >> front;
cut(0, middle.length() - 1, 0, front.length() - 1);
return 0;
}
void cut (int ms, int me, int fs, int fe) {
if (ms == me && fs == fe) {
cout << middle[ms];
return;
}
if (ms > me || fs > fe) {
return;
}
int x;
for (int i = ms; i <= me; i++) {
if (middle[i] == front[fs]) {
x = i;
}
}
cut(ms, x - 1, fs + 1, fs + x - ms);
cut(x + 1, me, fs + x - ms + 1, fs - ms + me);
cout << front[fs];
return;
}