关于小甲鱼C++课程单链表3的问题
void deleteNode(struct Node **head,int value){
struct Node *previous,*current;
current=*head;
previous=NULL;
while(current!=NULL && current->value!=value)
{
previous=current;
current=current->next;
}
if(current==NULL)
{
printf("找不到!\n");
return ;
}
else
{
if(previous==NULL)
{
*head=current->next;
}
else
{
previous->next=current->next;
}
}
free(current);
}
最后这个
previous->next=current->next;
不是很理解这行代码
current赋值给了previous 那他本身呢???
本帖最后由 jhq999 于 2021-12-14 16:49 编辑
previous->next=current->next;//是current->next赋值给了和previous->next,让current和previous办完交接,后面释放current
页:
[1]