diff --git a/cv5/a_train.c b/cv5/a_train.c index b9b28c0..5834f45 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -60,7 +60,7 @@ struct car* clear_train(struct car* first, const char* target) { } } struct car* this = first; - if(first->next->next == NULL){ + /*if(first->next->next == NULL){ int x = strcmp(this->next->value, target); if(x == 0){ struct car* secondlast = first; @@ -76,10 +76,18 @@ struct car* clear_train(struct car* first, const char* target) { } free(this); } - } + } */ + else{ while(this != NULL){ - int x = strcmp(this->value, target); + while(this != NULL){ + int x =strcmp(this->value, target); + if(x == 0){ + return NULL; + } + this = this->next + } + /*int x = strcmp(this->value, target); if(x == 0){ struct car* curr = first; struct car* prev = NULL; @@ -96,7 +104,7 @@ struct car* clear_train(struct car* first, const char* target) { prev->next = curr->next; free(this); } - this = this->next; + this = this->next;*/ } } return first;