大神求解数据结构,单链表,要c语言完整详解,急求,速度,大神给力!!!

2024-11-20 11:45:57
推荐回答(1个)
回答(1):

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;
}