From 1b5c0f5406502f691caba0c39f0d6a4e45d73124 Mon Sep 17 00:00:00 2001 From: vj586da Date: Fri, 5 Nov 2021 08:38:35 +0100 Subject: [PATCH] test --- cv4/a_train.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index f202840..2b9d0e5 100755 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -51,7 +51,7 @@ struct car* clear_train(struct car* first, const char* target) { return this; } } - if(this->next->next == NULL){ + /*if(this->next->next == NULL){ if(strcmp(this->value, target) == 0){ struct car* tmp = this->next; free(this); @@ -61,7 +61,7 @@ struct car* clear_train(struct car* first, const char* target) { this->next=NULL; return this; } - } + }*/ while( this->next->next != NULL){ if(strcmp(this->next->value, target) == 0){ struct car* third = this->next->next; @@ -73,13 +73,13 @@ struct car* clear_train(struct car* first, const char* target) { this = this->next; } } - if(strcmp(this->next->value, target) == 0){ + if(strcmp(this->value, target) == 0){ + struct car* tmp = this->next; + free(this); + return tmp; + }else if(strcmp(this->next->value, target) == 0){ free(this->next); - this->next=this->next->next; - return this; - }else if(strcmp(this->next->next->value, target) == 0){ - free(this->next->next); - this->next->next=NULL; + this->next=NULL; return this; } return first;