后序中序遍历问题 求原程序

[复制链接]
查看11 | 回复0 | 2007-5-3 13:52:49 | 显示全部楼层 |阅读模式
procedure Solve(mid,post:string);var i:integer;beginif (mid='''') or (post='''') then exit;i:=pos(post[length(post)],mid);pre:=pre+post[length(post)]; {加上根,递归结束后pre即为前序遍历}solve(copy(mid,1,I-1),copy(post,1,I-1));solve(copy(mid,I+1,length(mid)-I),copy(post,I,length(post)-i));end;这是一个用字符串实现的程序具体在做的时候把字符串改为数组就行了大概算法是这样的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行