没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
二叉树的遍历问题
描述
输入一棵二叉树的先序和中序遍历序列,输出其后序遍历序列。
输入
输入文件为 tree.in,共两行,第一行一个字符串,表示树的先序遍历,
第二行一个字符串,表示树的中序遍历。树的结点一律用小写字母表示。
输出
输出文件为 tree.out,仅一行,表示树的后序遍历序列。
样例输入
abdec
dbeac
样例输出
debca
---------------------------------------------------------------------
---------------------------------------------------------------------
#include<string.h>
using namespace std;
struct tree{
char data;
tree *l,*r;
};
tree * create(char pre[],char in[]){
tree *root;
if(strlen(pre)==0) {root=NULL;}
else{
root=new tree;
root->data=pre[0];
char pre1[20];pre1[0]='