思路:遍历整根链表,找到key,删掉key,找的时候p,q联动跑,找到后删除,分头删,中间尾删。
头删
h = h->next;
free(p);
p = h;
头删注意要将p拉回h
中间尾删
q->next = p->next;
free(p);
p = q->next;
一遍遍历完,删除完。
代码实现
运行环境:VS2017
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int date;
struct node*next;
}ElemSN;
//创建链表
ElemSN*GreatLink(int Date[], int n)
{
int i