clear
This commit is contained in:
parent
eaab488d65
commit
4aeb52f77e
@ -62,23 +62,33 @@ struct car* clear_train(struct car* first, const char* target) {
|
||||
return first;
|
||||
}
|
||||
}
|
||||
struct car* prev = first;
|
||||
while(prev->next->next != NULL){
|
||||
int x = strcmp(prev->next->value, target);
|
||||
struct car* this = first;
|
||||
while(this->next->next != NULL){
|
||||
int x = strcmp(this->next->value, target);
|
||||
if(x == 0){
|
||||
struct car* third = prev->next->next;
|
||||
free(prev->next);
|
||||
prev->next = third;
|
||||
return prev;
|
||||
struct car* curr = first;
|
||||
struct car* prev = NULL;
|
||||
if(first == this){
|
||||
first = this->next;
|
||||
free(this);
|
||||
return first;
|
||||
}
|
||||
prev = prev->next;
|
||||
while(curr != this){
|
||||
prev = curr;
|
||||
curr = curr->next;
|
||||
}
|
||||
prev->next = curr->next;
|
||||
this->next = NULL;
|
||||
free(this);
|
||||
}
|
||||
this = this->next;
|
||||
}
|
||||
|
||||
|
||||
int x = strcmp(prev->next->value, target);
|
||||
int x = strcmp(this->next->value, target);
|
||||
if(x == 0){
|
||||
free(prev->next);
|
||||
prev->next = NULL;
|
||||
free(this->next);
|
||||
this->next = NULL;
|
||||
return first;
|
||||
}
|
||||
return first;
|
||||
|
Loading…
Reference in New Issue
Block a user