clear
This commit is contained in:
parent
c484e99e36
commit
a12780d4aa
@ -59,8 +59,25 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct car* this = first;
|
||||||
|
if(first->next->next == NULL){
|
||||||
|
int x = strcmp(this->next->value, target);
|
||||||
|
if(x == 0){
|
||||||
|
struct car* secondlast = first;
|
||||||
|
while(this->next != NULL){
|
||||||
|
secondlast = this;
|
||||||
|
this = this->next;
|
||||||
|
}
|
||||||
|
if(this == first){
|
||||||
|
first = NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
secondlast->next = NULL;
|
||||||
|
}
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
struct car* this = first;
|
|
||||||
while(this != NULL){
|
while(this != NULL){
|
||||||
int x = strcmp(this->value, target);
|
int x = strcmp(this->value, target);
|
||||||
if(x == 0){
|
if(x == 0){
|
||||||
@ -84,4 +101,3 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
}
|
}
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user