This commit is contained in:
Maryna Kravtsova 2020-11-03 21:00:24 +01:00
parent c484e99e36
commit a12780d4aa

View File

@ -59,8 +59,25 @@ struct car* clear_train(struct car* first, const char* target) {
return 0;
}
}
else{
struct car* this = first;
if(first->next->next == NULL){
int x = strcmp(this->next->value, target);
if(x == 0){
struct car* secondlast = first;
while(this->next != NULL){
secondlast = this;
this = this->next;
}
if(this == first){
first = NULL;
}
else{
secondlast->next = NULL;
}
free(this);
}
}
else{
while(this != NULL){
int x = strcmp(this->value, target);
if(x == 0){
@ -84,4 +101,3 @@ struct car* clear_train(struct car* first, const char* target) {
}
return first;
}