clear
This commit is contained in:
parent
533abadd61
commit
2b24ea0449
@ -52,17 +52,21 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(first->next == NULL){
|
||||||
|
int result = strcmp(first->value, target);
|
||||||
|
if(result == 0){
|
||||||
|
free(first);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct car* prev = first;
|
struct car* prev = first;
|
||||||
while(prev->next != NULL){
|
while(prev->next != NULL){
|
||||||
int x = strcmp(first->value, target);
|
int x = strcmp(first->value, target);
|
||||||
if(x == 0){
|
if(x == 0){
|
||||||
if(first->next == NULL){
|
|
||||||
free(first);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
prev = first->next;
|
prev = first->next;
|
||||||
free(first);
|
free(first);
|
||||||
return prev;
|
return prev;
|
||||||
|
Loading…
Reference in New Issue
Block a user