#include "stdio.h"
#include "alloc.h"
struct shu
{
int data;
struct shu *lchild, *rchild;
};
struct shu * grate()
{
struct shu *t;
char ch;
printf ("enter a char\n");
scanf ("%c", &ch);
if (ch==' ')
t=NULL;
else {
t=(struct shu *) malloc (sizeof (struct shu));
t->data=ch;
t->lchild=grate ();
t->rchild=grate ();
}
return t;
}
void print (struct shu *p)
{
if (p==NULL)
printf ("error\n");
else{
printf ("%c", p->data);
print (p->lchild);
print (p->rchild);
}
}
main ()
{
struct shu *t ;
t=grate ();
print (t);
getch ();
}
为什么不能创建二叉树。