From a3c825715d77def189171fb09017db5fa374fe0d Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 27 Oct 2020 18:43:29 +0100 Subject: [PATCH] train2 --- cv5/a_train.c | 12 ++++++------ cv5/a_train.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 2d9a33d..9774063 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -31,19 +31,19 @@ void print_train(struct car* first) { } } -void cancel_train(struct car* first) { - struct car* this; +void cancel_train(struct car* first, int val) { if(first == NULL){ exit(0); } - else{ + else if(first->next == NULL){ + struct car* this; this = first; first = this->next; free(this); - cancel_train(first->next); - free(first); - } + cancel_train(first->next); + free(first); + } diff --git a/cv5/a_train.h b/cv5/a_train.h index 0297dfa..4088b1d 100644 --- a/cv5/a_train.h +++ b/cv5/a_train.h @@ -40,7 +40,7 @@ void print_train(struct car* first); * Zrusenie vsetkych voznov vo vlaku. * @arg smernik na prvy vozen */ -void cancel_train(struct car* first); +void cancel_train(struct car* first, int val); /** * Vyradenie vsetkych voznov, ktorych cielova stanica je target