连续删除链表结点

struct定义

1
2
3
4
5
struct Linklist
{
int data;
Linklist *next;
};

函数实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void deleteNode(LinkList *list)
{
int value;//要删除的结点数据
cin>>value;
Linklist *t = list->next,*in = list;
while(t != NULL)
{
Linklist *t = list ->next,* in = list;
while(t != NULL)
{
int is = 1;//判断是否查找到对象
if(t->date != age)is = 0;
if(is == 1)
{
in ->next = t->next;
delete(t);
break;
}
t = t->next;
in = in->next;
}
if(t == NULL)break;
}
}