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