/*
* ==============================================================
* File name: del_first_node_in_circular_list.c
* Author: 3360652783@qq.com
* Date created: 2026-07-23
* Description: Delete the first node in a circular singly linked list with head node.
* Copyright notice: All right Reserved
* ==============================================================
*/
//构建删除单向循环链表首结点的函数
bool FirstNode_del(*L)(){
CirLinkList *P; //用于暂存当前结点
if( L->next == L ){ //如果是个空表,则删除失败
return false;
}
p = L->next;
while( p->next != L->next ){ //遍历找到最后一个结点
p = p->next;
}
p->next = L->next->next; //将最后结点的指针指向第二个结点
p = L->next; //重复利用变量p,用于释放第一个结点的空间
L->next = p->next;
p->next = NULL;
free(p);
if( L->next == NULL ){ //如果删除首结点后仅剩头结点,则头结点的指针指向自己
L->next = L;
}
return true;
}