fix: reverse check for empty list

This commit is contained in:
Marian Gusatu
2020-04-22 11:44:47 +03:00
parent 5149a9f550
commit 7ed069648d

View File

@@ -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()