diff --git a/cv5/a_train.c b/cv5/a_train.c index 280f415..fc1d311 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -40,20 +40,21 @@ void print_train(struct car* first) { } void cancel_train(struct car* first) { - if(first == NULL){ - return; + if(!first){ + return NULL; } - else if(first->value != NULL){ - struct car* help = first->next; + struct car* help = cancel_train(first->next); + if(first->value != NULL){ + first->next = help; free(first); - //first->next = NULL; - cancel_train(help); + //cancel_train(help); //first->next = NULL; } - else if(first->next == NULL){ - free(first); - cancel_train(first->next); - } + //else if(first->next == NULL){ + //free(first); + // cancel_train(first->next); + // } + free(first); }