From 81eac89d184d103dfc98081e516b3d145b0e8013 Mon Sep 17 00:00:00 2001 From: Ivan Leichenko Date: Thu, 17 Oct 2024 23:02:31 +0200 Subject: [PATCH] correct cv4 --- cv4/a_train.c | 21 +++++++++++++++++++++ cv4/main.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 6c2afae..bfc56f4 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -76,6 +76,27 @@ struct car* clear_train(struct car* first, const char* target) } } struct car* prev = first; + + if(prev->next->next == NULL) + { + if(!strcmp(prev->value, target)) + { + struct car* second = prev->next; + free(prev); + first = second; + return first; + } + else if(!strcmp(prev->next->value, target)) + { + free(prev->next); + return first; + } + else + { + return first; + } + } + while (prev->next->next != NULL) { if(strcmp(prev->value, target)) diff --git a/cv4/main.c b/cv4/main.c index ee71136..2b056f6 100644 --- a/cv4/main.c +++ b/cv4/main.c @@ -1,4 +1,4 @@ -#include "a_train.h" +#include "a_train.c" #include #include