From 75787c17f99b950027c399065395643f1f735cef Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Thu, 5 Nov 2020 20:44:57 +0100 Subject: [PATCH] 57% --- cv5/a_train.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index da090e8..844c522 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -27,29 +27,26 @@ struct car* add_car(struct car* first,const char* target) { } void print_train(struct car* first) { -if(first!=NULL){ struct car* this=first; while(this->next!=NULL){ printf("%s",this->value); this=this->next; } } -} void cancel_train(struct car* first) { + } struct car* clear_train(struct car* first, const char* target) { struct car* prev = first; -// Už sme si istí, že prev a prev->next nie sú NULL -// while (prev->next->next != NULL){ - // prev = prev->next; - //} - //struct car* third = prev->next->next; - //free(prev->next); - //prev->next = third; - //return first; - - return NULL; -} + //Už sme si istí, že prev a prev->next nie sú NULL + while (prev->next->next != NULL){ + prev = prev->next; + } + struct car* third = prev->next->next; + free(prev->next); + prev->next = third; + return first; + }