clear
This commit is contained in:
parent
33a7361c9d
commit
549a6793f6
@ -62,24 +62,25 @@ 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(temp != NULL){
|
while(prev->next->next != NULL){
|
||||||
int x = strcmp(temp->value, target);
|
int x = strcmp(prev->next->value, target);
|
||||||
if(x != 0){
|
if(x == 0){
|
||||||
prev = temp;
|
struct car* third = prev->next->next;
|
||||||
temp = temp->next;
|
free(prev->next);
|
||||||
|
prev->next = third;
|
||||||
|
return third;
|
||||||
}
|
}
|
||||||
else{
|
prev = prev->next;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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