This commit is contained in:
Maryna Kravtsova 2020-11-03 21:12:51 +01:00
parent a12780d4aa
commit 4c61a14372

View File

@ -60,7 +60,7 @@ struct car* clear_train(struct car* first, const char* target) {
} }
} }
struct car* this = first; struct car* this = first;
if(first->next->next == NULL){ /*if(first->next->next == NULL){
int x = strcmp(this->next->value, target); int x = strcmp(this->next->value, target);
if(x == 0){ if(x == 0){
struct car* secondlast = first; struct car* secondlast = first;
@ -76,10 +76,18 @@ struct car* clear_train(struct car* first, const char* target) {
} }
free(this); free(this);
} }
} } */
else{ else{
while(this != NULL){ 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){ if(x == 0){
struct car* curr = first; struct car* curr = first;
struct car* prev = NULL; struct car* prev = NULL;
@ -96,7 +104,7 @@ struct car* clear_train(struct car* first, const char* target) {
prev->next = curr->next; prev->next = curr->next;
free(this); free(this);
} }
this = this->next; this = this->next;*/
} }
} }
return first; return first;