思路:用一个指针p遍历链表,然后对每次p之后的元素查看是否有相同元素
示例:
list RemoveDupNode(list l){
position p, q, t;
p = l->next;
while (p){
q = p;
while (q->next){
if (q->next->data == p->data){
t = q->next;
q->next = t->next;
free(t);
}
else q = q->next;
}
p = p->next;
}
return l;
}