clear train hell cv4
This commit is contained in:
parent
4d12d1de23
commit
090dc461f3
@ -76,6 +76,8 @@ struct car* clear_train(struct car* first, const char* target)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct car* prev = first;
|
struct car* prev = first;
|
||||||
|
struct car* bef_prev = first;
|
||||||
|
|
||||||
|
|
||||||
if(prev->next->next == NULL)
|
if(prev->next->next == NULL)
|
||||||
{
|
{
|
||||||
@ -98,17 +100,44 @@ struct car* clear_train(struct car* first, const char* target)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (prev->next->next != NULL)
|
while (prev->next->next != NULL)
|
||||||
{
|
{
|
||||||
if(strcmp(prev->value, target))
|
if(!strcmp(prev->value, target))
|
||||||
{
|
{
|
||||||
struct car* third = prev->next->next;
|
struct car* third = prev->next->next;
|
||||||
free(prev->next);
|
free(prev->next);
|
||||||
prev->next = third;
|
prev->next = third;
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
if(prev->next->next != NULL)
|
||||||
|
{
|
||||||
|
bef_prev = prev;
|
||||||
|
}
|
||||||
prev = prev->next;
|
prev = prev->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(prev->next->next == NULL)
|
||||||
|
{
|
||||||
|
if(!strcmp(prev->value, target))
|
||||||
|
{
|
||||||
|
struct car* last = prev->next;
|
||||||
|
free(prev);
|
||||||
|
bef_prev->next = last;
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
else if(!strcmp(prev->next->value, target))
|
||||||
|
{
|
||||||
|
free(prev->next);
|
||||||
|
prev->next = NULL;
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user