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