p指向当前结点,q指向下一结点,若相等删除q,并把q指向下一个,继续操作
struct Node{
int Value;
Node *Next;
.......;
};
(简单假设值比较为int Value 相等);
Node *Head;(表头)
Node *Temp1 = Head;
Node *Temp2;
while(Temp1){
Temp2 = Temp1-> Next;
whiel(Temp2){
if(Temp2-> Value == Temp1-> Value){
Node *Temp = Temp2-> Next;
.....(删除Temp2,如free(Temp2))
Temp2 = Temp;
}else Temp2 = Temp2-> Next;
}
Temp1 = Temp1-> Next;
}