已知带头结点的单链表L,指针P指向L链表中的一个结点为(非首结点、非尾结点),

2025-01-04 09:48:22
推荐回答(2个)
回答1:

题目没写清楚,不完整,不好回答

回答2:

1. L *Q;
P->next = Q;
P->next = Q->next;
free(Q);
2 L *Q,*R;
R->next = Q;
Q->next = P;
R->next = P;
free(Q);
3 L *Q;
Q->next = P;
Q->next = P->next;
free(P);
4 L * p,q;
p = head;
q = p->next;
head = q;
free(p);
return head;
5. L *p,s;
p = head;
s = p->next;
while(s->next)
{
p = s;
s = s->next;
}
p->next = NULL;
free(s);