clear
This commit is contained in:
parent
8fd5decb45
commit
a957a8266f
@ -62,24 +62,25 @@ struct car* clear_train(struct car* first, const char* target) {
|
||||
return first;
|
||||
}
|
||||
}
|
||||
struct car* this = first;
|
||||
while(this->next != NULL){
|
||||
int x = strcmp(this->value, target);
|
||||
struct car* prev = first;
|
||||
while(prev->next->next != NULL){
|
||||
int x = strcmp(prev->value, target);
|
||||
if(x == 0){
|
||||
struct car* third = this->next->next;
|
||||
if(first == this){
|
||||
first = this->next;
|
||||
free(this);
|
||||
return first;
|
||||
}
|
||||
else {
|
||||
free(this->next);
|
||||
this->next = third;
|
||||
}
|
||||
}
|
||||
this = this->next;
|
||||
}
|
||||
first = NULL;
|
||||
first = prev->next;
|
||||
free(prev);
|
||||
|
||||
}
|
||||
x = strcmp(prev->next->value, target);
|
||||
if(x == 0){
|
||||
if(first->next->next == NULL) {
|
||||
//struct car* tmp = prev->next;
|
||||
free(prev->next);
|
||||
prev->next = NULL;
|
||||
}
|
||||
}
|
||||
prev = prev->next;
|
||||
}
|
||||
return first;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user