`## 在有序链表中插入一个数,并使它仍是个有序表
LinkList* Push(LinkList* head,int val)
{
LinkList* newnode,cur;
newnode = (struct LinkList)malloc(sizeof(LinkList));//建立一个新节点
newnode->data = val;
newnode->next = NULL;
cur = head;
while(cur->next != NULL&&cur->next->data < val)
{
cur = cur->next;
}
newnode->next = cur->next;
cur->next = newnode;
return head;
}
在有序链表中插数
最新推荐文章于 2023-04-05 14:57:48 发布