Home > Back-end >  Why do I this delete function has a problem? , can help the younger brother have a look at it
Why do I this delete function has a problem? , can help the younger brother have a look at it

Time:10-02

Why I delete 2 it would delete the position of the 3, I lose 3 it is no place to complain, I find it will be to delete a below this is why

CodePudding user response:

First of all, you want to delete a node to save point being abridged a node before and after a node, you debug your listdelete logic, you have saved before a node is deleted node? Suggest drawing first to understand the rules of the link!

CodePudding user response:

Do you have established the three, and then after you each element on a

CodePudding user response:

Do you have established the three, and then you after each element by a

CodePudding user response:

reference 1/f, to be continued _1006 response:
the first thing you want to delete a node to keep abridged point is a node before and after a node, you debug your listdelete logic, you have saved before a node is deleted node? Suggest drawing first to understand the rules of the link!

Not quite understand this logic, bosses can help me speak according to this problem

CodePudding user response:

reference 1/f, to be continued _1006 response:
the first thing you want to delete a node to keep abridged point is a node before and after a node, you debug your listdelete logic, you have saved before a node is deleted node? Suggest drawing first to understand the rules of the link!

I only know to quote a new pointer, save that the deleted, and then release

CodePudding user response:

The
reference 3 floor (' del `)? The Program (' del `)? Response:
if you have set up three, then after you each element on a

I also don't know much about you know

CodePudding user response:

You need to get to delete the previous node of the node, rather than the node itself is to be deleted, the node is to be deleted before the next point to a node in the node is to be deleted after a node is deleted

CodePudding user response:

refer to 7th floor 燚 recognition response:
you need to get the before a node to node is to be deleted, rather than the node itself is to be deleted, the node is to be deleted before the next point to be deleted from a node of a node is deleted after

Code should be how to achieve, I still don't know much about the complex logic??

CodePudding user response:



Linklist * q=L, * k=q - & gt; Next;
//L have a head node, q point to the first node, no data, k points to the first node
//position starting from 0 count, that is, n of 0 delete the first node
For (int I=0; K & amp; & (I & lt; n); The k + + I)//here as a condition of judgment, prevent excessive
{
//q is k always maintain a node before
Q=k;
K=k - & gt; Next;
}
//end of the cycle is k, pointing to the node to delete, q is a node before his
Q - & gt; Next=k - & gt; Next;
Free (k);

CodePudding user response:

You stick the code, I give you modify the filling
  • Related