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;
|
return first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct car* prev = first;
|
struct car* this = first;
|
||||||
while(prev->next->next != NULL){
|
while(this->next->next != NULL){
|
||||||
int x = strcmp(prev->next->value, target);
|
int x = strcmp(this->next->value, target);
|
||||||
if(x == 0){
|
if(x == 0){
|
||||||
struct car* third = prev->next->next;
|
struct car* curr = first;
|
||||||
free(prev->next);
|
struct car* prev = NULL;
|
||||||
prev->next = third;
|
if(first == this){
|
||||||
return prev;
|
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){
|
if(x == 0){
|
||||||
free(prev->next);
|
free(this->next);
|
||||||
prev->next = NULL;
|
this->next = NULL;
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
return first;
|
return first;
|
||||||
|
Loading…
Reference in New Issue
Block a user