train
This commit is contained in:
parent
8e6497b6e8
commit
7bd7f9c076
@ -45,7 +45,7 @@ void print_train(struct car* first) {
|
|||||||
|
|
||||||
void cancel_train(struct car* first) {
|
void cancel_train(struct car* first) {
|
||||||
if(first == NULL){
|
if(first == NULL){
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
if(first->next != NULL){
|
if(first->next != NULL){
|
||||||
cancel_train(first->next);
|
cancel_train(first->next);
|
||||||
@ -65,14 +65,27 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
if(first == NULL){
|
if(first == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
struct car* this = first;
|
int x;
|
||||||
while(this != NULL){
|
if(first->next == NULL){
|
||||||
if(this->value == target){
|
x = strcmp(first->value; target);
|
||||||
return NULL;
|
if(x == 0){
|
||||||
}
|
free(first);
|
||||||
this = this->next;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return first;
|
else{
|
||||||
|
struct car* prev = first;
|
||||||
|
while(prev->next->next != NULL){
|
||||||
|
x = strcmp(prev->next->value, target);
|
||||||
|
if(x == 0){
|
||||||
|
struct car* third = prev->next->next;
|
||||||
|
free(prev->next);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prev = prev->next;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user