创建二叉搜索书出错..不知道问题在哪里
如题,不知道那里出错了,请大家指点一下.
谢谢
代码如下:
#include<iostream>
using namespace std;
struct bintree
{
int data;
bintree * left;
bintree * right;
};
void insert(bintree *&bt,int x)
{
bintree *p=new bintree;
p->data=x;
p->left=p->right=NULL;
if(bt==NULL)
bt=p;
else
{
if(x<bt->data)
insert(bt->left,x);
else
insert(bt->right,x);
}
}
void disp(bintree *bt)
{
while(bt)
cout<<bt->data<<endl;
disp(bt->left);
disp(bt->right);
}
void main()
{
bintree *h;
insert(h,3);
insert(h,4);
insert(h,7);
insert(h,9);
disp(h);
}