Given a number x, write a program to delete all occurrences of x from a linked list
in one iteration. That is, you can not scan the list more than once.
It only deletes the first occurrence of X, can someone help fixing it please?
Node* one = new Node(5);
Node* two = new Node(5);
Node* three = new Node(3);
Node* four = new Node(4);
Node* five = new Node(5);
Node* six = new Node(6);
h=one;
one->next=two;
two->next=three;
three->next=four;
four->next=five;
five->next=six;
DelAcc(h, 5);
i tried these values, and it is not working correctly, it only deletes the second and the fifth but not the first!!! and you keep telling me that you gave me the answer and i kept saying it not working correctly.
Consider the control expression. The only time head->value == X is evaluated is when !head->next evaluates to a non-zero value. The only time !head->next evaluates to a non-zero value is when head->next is NULL. This means that the only time you check to see if head contains X is when head is the only member of the list.