diff --git a/cv5/a_train.c b/cv5/a_train.c index 3365ec0..7a9aa9a 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -72,13 +72,12 @@ struct car* clear_train(struct car* first, const char* target) { } x = strcmp(prev->next->value, target); - // if(x == 0){ - /* if(first->next->next == NULL) { - //struct car* tmp = prev->next; - free(prev->next); - prev->next = NULL; - }*/ - //} + if(x == 0){ + struct car* third = prev->next->next; + free(prev->next); + prev->next = third; + + } prev = prev->next; } if(prev->next->next == NULL) { @@ -89,6 +88,13 @@ struct car* clear_train(struct car* first, const char* target) { return prev; } + x = strcmp(prev->next->value, target); + if(x == 0){ + struct car* third = prev->next->next; + free(prev->next); + prev->next = third; + } + //free(prev->next); //prev->next = NULL; }