Updated the add last element inti linkedlist

This commit is contained in:
Sambo Chea 2020-08-01 21:59:39 +07:00
parent cdb08a328e
commit b9356d3bc3
2 changed files with 6 additions and 3 deletions

Binary file not shown.

View File

@ -122,11 +122,13 @@ void add_last(int element)
{
head = node;
head->next = NULL;
printf("Element %d has been add into first/last!\n", element);
return;
}
// store current as tempo
temp = node;
temp = head;
while (temp->next != NULL)
{
@ -135,6 +137,7 @@ void add_last(int element)
temp->next = node;
node->next = NULL;
head = temp;
}
void traverse()