void creat(BTnode *b) //用递归的方法建立一个二叉树,先序遍历,用输入字符串的方式建立,当输入空格的时候为空树
{
char ch;
ch=getchar();
getchar();
if(ch==' ')b=NULL;
else
{b=(BTnode *)malloc(sizeof(BTnode));
b->data=ch;
creatmi(b->lchild);/*creatmi改为creat试试?因为前面没有creatmi函数,这样写不行啊*/
creatmi(b->rchild);}
}
Private Sub preorder(a As sbnode)
Dim a1 As sbnode, a2 As sbnode ’改成 这样就可以了
If a.lcd = 0 And a.rcd = 0 Then
Print a.Data;
Else
If a.lcd <> 0 Or a.rcd <> 0 Then
a1 = a.lcd
a2 = a.rcd
Print a.Data
Call preorder(tree(a1))
Call preorder(tree(a2))
End If
End If
End Sub