#include <iostream> #include <string> using namespace std; struct treenode { char data; treenode* left = NULL; treenode* right = NULL; }; void built(treenode*& root, string pre, string mid) { // if if (pre==""&&mid=="") { //cout << root->data; return; } root = new treenode; root->data = pre[0]; int pos = mid.find(pre[0]);//找到分界点 built(root->left, pre.substr(1, pos), mid.substr(0, pos)); built(root->right, pre.substr(pos + 1), mid.substr(pos + 1)); cout << root->data; } int main() { string pre, mid; while (cin >> pre >> mid) { // 注意 while 处理多个 case treenode* root = NULL; built(root, pre, mid); puts(""); } } // 64 位输出请用 printf("%lld")