删除

删除

bool LList_TailInsert(LList_t *Head,DataType_t data)
{
    if (NULL == Head)
    return false;
    
    //对链表的头文件的地址进行备份
	LList_t *Phead = Head;
	LList_t *lhead = Head;
	
	//首结点
	while(Phead->next != NULL)
	{
		//把头的直接后继作为新的头结点
		Phead = Phead->next;
        lhead = Phead;

	}
    lhead->next = NULL;//找到尾节点的前驱,把尾节点给断开
    free(Phead);

    return true;
}

bool LList_DestInsert(LList_t *Head,DataType_t dest,DataType_t data)
{
    if (NULL == Head)
    return false;
    //对链表的头文件的地址进行备份
	LList_t *Phead = Head;
	LList_t *lhead = Head;
	Phead = Phead->next;
    lhead = Phead;
	while(Phead->next != NULL)
	{
        if (Phead->data == data)
        {
            lhead->next = Phead->next;
            Phead->next = NULL;
            free(Phead);
            return true;   
        }
		//把头的直接后继作为新的头结点
        lhead = Phead;
		Phead = Phead->next;
	}

}
posted @ 2024-04-22 21:39  Ikin粉  阅读(26)  评论(0)    收藏  举报