关于二叉树的问题,不知道错在那了,请高手指教

[复制链接]
查看11 | 回复1 | 2011-10-16 06:21:20 | 显示全部楼层 |阅读模式
#includeiostream.hstructtree{chardata;structtree*letf;structtree*right();};intn=1;structtree*create(){inti=n;chars;structtree*p=NULL;cout\"输入根节点(.结束):\";cins;if(s!=\'.\'){n;p=newstructtree;p-data=s;cout\"输入第\"i\"个节点左孩子\";p-letf=create();cout\"输入第\"i\"个节点右孩子\";p-right=create();}returnp;}voidpreorder(tree*root){if(root){coutroot-data;preorder(root-letf);preorder(root-right);}coutendl;}voidmain(){tree*root;root=create();preorder(root);}随便能不能详细讲解一下。谢谢了。
回复

使用道具 举报

千问 | 2011-10-16 06:21:20 | 显示全部楼层
structtree*right();多了括号,其他没什么错误。
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行