#include<stdio.h> #include<string.h> int n; void find(char *src, char *str, char *c, char *left, char *right) { char *cnext; if (left == right) { printf("%c", *c); return; } cnext = strchr(src, *(str+n)); if (cnext >= left && cnext <= c) { n++; find(src, str, cnext, left, c-1); } cnext = strchr(src, *(str+n)); if (cnext >= c && cnext <= right) { n++; find(src, str, cnext, c+1, right); } printf("%c", *c); } main() { char str[27], src[27]; while (scanf("%s %s", str, src) != EOF) { n = 1; find(src, str, strchr(src, *str), src, src+strlen(src)-1); printf("\n"); } }