利用前序,中序,求出后序遍历
#include <stdio.h>
#include <string.h>
#define N 105
char *move = NULL;
char str1[N], str2[N];
void reback(int a, int b)
{
if(a == b)
return;
for(int i = a; i < b; i++){
if(str2[i] == *move){
move++;
reback(a, i);
reback(i+1, b);
putchar(str2[i]);
}
}
}
int main( int argc, const char* argv[] )
{
while(scanf("%s%s", str1, str2)!=EOF){
move = str1;
reback(0, strlen(str2));
printf("\n");
}
return 0;
}