标题:有关二叉树的小问题
取消只看楼主
MyStar
Rank: 1
等 级:新手上路
帖 子:75
专家分:9
注 册:2010-3-30
结帖率:93.75%
已结贴  问题点数:20 回复次数:1 
有关二叉树的小问题
#include <iostream>
using namespace std;
struct BiNode
{
char data;
BiNode *lchild ,*rchild;
};
BiNode *Creat()
{
    char ch;BiNode *root;
   
cin>>ch;
if(ch=='#') root=NULL;//建立一颗空树
else{
        root=new BiNode;
        root->data=ch;
        //cout<<root->data;
        root->lchild=Creat();//递归建立左子树
        root->rchild=Creat();//递归建立右子树
    }
return 0;
}

void output(BiNode *root)
{
    if(root!=NULL)
     cout<<root->data<<endl;
     output(root->lchild);
     output(root->rchild);
   
}
int main()
{
    BiNode *a;
    Creat();
    output(a);
    return 0;
}
程序不知怎么没输出结果!!!请大家指点一下!!谢谢

搜索更多相关主题的帖子: 二叉树 
2010-05-22 16:59
MyStar
Rank: 1
等 级:新手上路
帖 子:75
专家分:9
注 册:2010-3-30
得分:0 
谢谢啦!!
2010-05-22 20:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-307743-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.212455 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved