//============================================================================
// Name : ����ɾ����.cpp
// Author : Lucas
// Version :
// Copyright : @Lucas
// Description : 1.是不是头结点。 2.不是头结点,用临时节点存放要被删除的结点,后面的覆盖要被删除的节点,最后删除结点。
//============================================================================
#include <iostream>
using namespace std;
struct node
{
int data;
node *next;
};
void deleteNode(node **head, int value)
{
if (head == NULL || *head == NULL)
{
return;
}
node *tmpHead = *head;
while ((tmpHead)->data != value && (tmpHead->next != NULL))
{
tmpHead = tmpHead->next;
}
if (tmpHead->data != value)
{
return;
}
if (tmpHead == *head)
{
*head = tmpHead->next;
delete tmpHead;
}
node *nodeToBeDelete = NULL;
tmpHead = tmpHead->next;
delete nodeToBeDelete;
}
int main() {
return 0;
}