遍历链表,如果当前结点的值在之前的结点中出现过,那么删除当前结点
追问那算法是怎么样的啊?
追答大概类似这样:
void unique(List *li)
{
Node *head, *p, *q;
head = p = li->head;
while (p->next != NULL)
{
q = head;
while (q != p->next)
{
if (p->next->data == q->data)
{
q = p->next;
p->next = q->next;
free(q);
break;
}
q = q->next;
}
p = p->next;
}
}
本回答被提问者和网友采纳