①二叉树结点类型
typedef struct node
{
char data;
struct node *left, *right;
}Btnode;
②二叉树的创建
void CreateBinary_tree(Btnode * &s)
{
char t;
cin >> t;
if (t == '#') //‘#’代表此处结点为空的前提下
s = NULL;
else
{
s = new Btnode; //C语言的则改为:s = (btnode *)malloc(sizeof(btnode));
s->data = t;
s->left = s->right = NULL;
CreateBinary_tree(s->left);
CreateBinary_tree(s->right);
}
}