二叉木の先序の遍歴を求めます
799 ワード
タイトルの説明
すでに1本の二叉木の中序遍歴と後序遍歴を知っていて、二叉木の先序遍歴を求めます
入力
入力データには複数のグループがあり、最初の行は整数t(t<1000)であり、tグループのテストデータを表す.各グループには、50未満の長さの2つの文字列が含まれ、1番目の文字列はツリーの中順遍歴シーケンスを表し、2番目の文字列はツリーの後順遍歴シーケンスを表す.
しゅつりょく
出力ツリーのシーケンスループシーケンス
サンプル入力
サンプル出力
すでに1本の二叉木の中序遍歴と後序遍歴を知っていて、二叉木の先序遍歴を求めます
入力
入力データには複数のグループがあり、最初の行は整数t(t<1000)であり、tグループのテストデータを表す.各グループには、50未満の長さの2つの文字列が含まれ、1番目の文字列はツリーの中順遍歴シーケンスを表し、2番目の文字列はツリーの後順遍歴シーケンスを表す.
しゅつりょく
出力ツリーのシーケンスループシーケンス
サンプル入力
2
dbgeafc
dgebfca
lnixu
linux
サンプル出力
abdegcf
xnliu
#include
#include
struct node
{
char data;
struct node *lch,*rch;
};
void pai(char *xian,char *zhong,int len)
{
if(len==0)
return ;
node *t=new node;
t->data=*xian; printf("%c",t->data);
int i=0;
for(;i