UVA 536(p177)----Tree Recovery

var
post,st1,st2,st:ansistring;
l:longint;
procedure solve(pre,mid:ansistring);
var i:integer;
begin
 if (pre='') or (mid='') then exit;
 i:=pos(pre[1],mid);
 solve(copy(pre,2,i),copy(mid,1,i-1));
 solve(copy(pre,i+1,length(pre)-i),copy(mid,i+1,length(mid)-i));
 post:=post+pre[1];
end;
begin
 while(not eof)do
  begin
   readln(st);
   post:='';
   l:=pos(' ',st);
   st1:=copy(st,1,l-1);
   st2:=copy(st,l+1,length(st));
   solve(st1,st2);
   writeln(post);
  end;
end.
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=477

你可能感兴趣的:(UVA 536(p177)----Tree Recovery)