0
点赞
收藏
分享

微信扫一扫

链表相关习题:任意删除一个节点

自由情感小屋 2022-03-12 阅读 103

 

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "list.h"

//删除任意一个节点(这个节点不能是尾结点)(狸猫换太子)
bool Del_Node(struct Node* p)
{
	assert(p != NULL);//确保p存在
	assert(p->next != NULL); //确保狸猫的存在(p不能是尾结点)

	PNode q = p->next;

	p->data = q->data;
	p->next = q->next;
	free(q);

	return true;
}
举报

相关推荐

0 条评论