mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-13 10:29:43 +08:00
Update Linked List.cpp
fix: reverse check for empty list + converting tabs to spaces
This commit is contained in:
@@ -101,15 +101,14 @@ void reverse()
|
||||
{
|
||||
node *first = start;
|
||||
if (first != NULL){
|
||||
node *second = first->next;
|
||||
while (second != NULL)
|
||||
{
|
||||
node *tem = second->next;
|
||||
second->next = first;
|
||||
first = second;
|
||||
second = tem;
|
||||
}
|
||||
|
||||
node *second = first->next;
|
||||
while (second != NULL)
|
||||
{
|
||||
node *tem = second->next;
|
||||
second->next = first;
|
||||
first = second;
|
||||
second = tem;
|
||||
}
|
||||
start->next = NULL;
|
||||
start = first;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user