结构体为:
typedef struct LNode{
int data;
struct LNode *next;
}LNode,*LinkList;
算法段:
void Delete(LinkList &L)
{
LNode *p = L->next;
LNode *pre;
LNode *q;
LNode *t;
while(p->next != NULL)
{
pre = p;
q = pre->next;
while(q != NULL)
{
if(p->data == q->data)
{
t = q;
pre->next = q->next;
q = pre->next;
delete t;
}else{
q = q->next;
pre = pre->next;
}
}
p = p->next;
}
}