Answer the question
In order to leave comments, you need to log in
How to move an element to the end of a singly-directed list?
I tried in different ways, but I can’t cope with the links :(
It seems that I understand in my head what is wrong and what needs to be done, but I can’t implement it.
Please help. Thank you :)
PS Functions for deleting, inserting, etc., if necessary, I will provide!
nd = lst->head;
nd1 = lst->head;
for (i = 0; nd != lst->tail; i++) {
j = 0;
nd1 = nd->next;
for (; nd1 != lst->tail; j++) {
if ((nd1->info == nd->info) && (nd1->key != nd->key)) {
insertAfterList(lst, nd1, nd1->key);
deleteList(lst, nd1->key);
}
if (nd1->next != NULL)
nd1 = nd1->next;
}
nd = nd->next;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question