标签:lex nbsp bsp dll creat head child bin malloc
_declspec(dllexport) Node::TNODE* create_binary_sort_tree(Node::RECORD TEST[], int maxlen); //二叉排序树的创建
Node::TNODE* tree::create_binary_sort_tree(Node::RECORD TEST[], int maxlen) //二叉排序树的创建
{
int i;
Node::TNODE *head, *s, *p, *q;
head = NULL;
for (i = 0; i < maxlen; i++)
{
s = (Node::TNODE*)malloc(sizeof(Node::TNODE));
s->lchild = NULL;
s->rchild = NULL;
s->data = TEST[i].k;
if (head == NULL)
head = s;
else
{
p = head;
q = p;
while (p != NULL)
{
q = p;
if (p->data > s->data)
p = p->lchild;
else
p = p->rchild;
}
if (q->data > s->data)
q->lchild = s;
else
q->rchild = s;
}
}
return head;
标签:lex nbsp bsp dll creat head child bin malloc
原文地址:https://www.cnblogs.com/lu20191227/p/12108052.html