| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
shui#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
void printPos(char *pre, char *in, int len){
if(!len) return;
char root = pre[0];
int pos;
for(int i = 0; i < len; i++){
if(in[i] == root){
pos = i;
break;
}
}
printPos(pre+1, in, pos);
printPos(pre+1+pos, in+pos+1, len-pos-1);
printf("%c", root);
}
int main() {
char pre[30], in[30];
while(scanf("%s%s", pre, in) == 2){
int len = strlen(pre);
printPos(pre, in, len);
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator