listnodep insert_mid(listnodep head, listnodep newnode) //按排序顺序进行链表的建立
{
if (head == NULL)
head = newnode;
listnodep temp = head;
listnodep pre;
while (temp->nextptr != NULL)
{
if (newnode->data > temp->data)
{
pre = temp;
temp = temp->nextptr;
}
else
break;
}
pre->nextptr = newnode;
newnode->nextptr = temp;
return head;
}
这是我刚刚写的一个调用函数,实现的功能:按升序顺序进行链表排列;传入的参数:指向链表的头指针,要插入新的结点;
但是没有达到想要实现的功能,请大神赐教