#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string.h>
using namespace std;
char pre[55], in[55];
vector<char> post;
int search(char* s, char c){
for (int i = 0; i < strlen(s); ++i)
if(s[i] == c)
return i;
return -1;
}
void FindPost(char* _in, char* _pre, int len){
int root = search(_in, _pre[0]);
if(root > 0)
FindPost(_in, _pre + 1, root);
if(root < len - 1)
FindPost(_in + root + 1, _pre + root + 1, len - root - 1);
post.push_back(_pre[0]);
}
int main(){
while(scanf("%s", pre) != EOF){
scanf("%s", in);
post.clear();
FindPost(in, pre, strlen(in));
for (int i = 0; i < post.size(); ++i)
printf("%c", post[i]);
printf("\n");
}
}
2015年2月12日 星期四
TIOJ 1108 樹的三兄弟
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言