帮忙看下下面代码输出树错哪了
#include<stdio.h>#include<stdlib.h>
void shuru(int x,struct shu*);
void shuchu(struct shu*);
struct shu
{
int data;
struct shu *lson,*rson;
};
main()
{struct shu* p;
p=NULL;
int x;
while(scanf("%d",&x))
shuru(x,p);
shuchu(p);
}
void shuru(int x,struct shu*p)//构造树
{struct shu *i,*k;
k=NULL;
i=p;
while(i)
{if(i->data>=x)
k=i,i=i->lson;
else
k=i,i=i->rson;}
i=(struct shu*) malloc(sizeof(struct shu));
i->data=x;i->lson=i->rson=NULL;
if(k==NULL)
p=i;
else
{if(k->data>=x)
k->lson=i;
else
k->rson=i;}
}
void shuchu(struct shu*p)//中序序列输出树
{if(p==NULL)return;
shuchu(p->lson);
printf("%d",p->data);
shuchu(p->rson);
}