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