mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-13 07:25:42 +08:00
fix: reverse check for empty list
This commit is contained in:
@@ -100,17 +100,19 @@ void show()
|
||||
void reverse()
|
||||
{
|
||||
node *first = start;
|
||||
node *second = first->next;
|
||||
while (second != NULL)
|
||||
{
|
||||
node *tem = second->next;
|
||||
second->next = first;
|
||||
first = second;
|
||||
second = tem;
|
||||
}
|
||||
if (first != NULL){
|
||||
node *second = first->next;
|
||||
while (second != NULL)
|
||||
{
|
||||
node *tem = second->next;
|
||||
second->next = first;
|
||||
first = second;
|
||||
second = tem;
|
||||
}
|
||||
|
||||
start->next = NULL;
|
||||
start = first;
|
||||
start->next = NULL;
|
||||
start = first;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
Reference in New Issue
Block a user