#include<stdio.h>
#include<math.h>
#define OK 1
#define ERROR -1
typedef int Status ;
typedef int ElemType ;
typedef struct Lnode{
ElemType data; /*数据域,保存结点的值 */
struct Lnode *next; /*指针域*/
} LNode; /*结点的类型 */
void Delete_LinkList(LNode *L,int key)
/* 删除以L为头结点的单链表中值为key的第一个结点 */
{
// p为q前面的节点
LNode *p=L,*q=L->next;
while ( q!=NULL&& q->data!=key){
p=q; q=q->next;
}
// 当找到这个值是,删除q结点,释放资源;
if (q->data==key){
p->next=q->next; free(q);
}
else
printf("所要删除的结点不存在!!\n");
}
C语言链表按值删除
最新推荐文章于 2023-08-15 06:00:00 发布