Изменил(а) на 'cv4/a_train.c'

This commit is contained in:
Oleksandr Hryshchenko 2021-11-25 23:04:07 +00:00
parent baa6822782
commit dc2f9da046

View File

@ -2,40 +2,22 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "a_train.h" #include "a_train.h"
<<<<<<< HEAD
struct car* add_car(struct car* first, const char* target){
if(!strcmp(target, ""))
return NULL;
if(!first){
=======
struct car* add_car(struct car* first, const char* target){ struct car* add_car(struct car* first, const char* target){
if(!strcmp(target, "")) if(!strcmp(target, ""))
return NULL; return NULL;
if(!first || !strcmp(first->value, "")){ if(!first || !strcmp(first->value, "")){
>>>>>>> 2033291145353cf5a29605aaa70523464ca047fa
first = (struct car*)calloc(1, sizeof(struct car)); first = (struct car*)calloc(1, sizeof(struct car));
strcpy(first->value, target); strcpy(first->value, target);
first->next = NULL; first->next = NULL;
return first; return first;
} }
<<<<<<< HEAD
struct car* temp = first; struct car* temp = first;
while(temp->next != NULL) while(temp->next != NULL)
temp = temp->next; temp = temp->next;
=======
struct car* temp = first;
while(temp->next != NULL)
temp = temp->next;
>>>>>>> 2033291145353cf5a29605aaa70523464ca047fa
temp->next = (struct car*)calloc(1, sizeof(struct car)); temp->next = (struct car*)calloc(1, sizeof(struct car));
strcpy(temp->next->value, target); strcpy(temp->next->value, target);
temp->next->next = NULL; temp->next->next = NULL;
@ -54,7 +36,6 @@ void print_train(struct car* first){
void cancel_train(struct car* first){ void cancel_train(struct car* first){
if(!first) if(!first)
return; return;
<<<<<<< HEAD
struct car* temp = first; struct car* temp = first;
struct car* next = temp->next; struct car* next = temp->next;
@ -65,18 +46,6 @@ void cancel_train(struct car* first){
temp = next; temp = next;
} }
=======
struct car* temp = first;
struct car* next = temp->next;
while(next != NULL){
next = temp->next;
free(temp);
temp = next;
}
>>>>>>> 2033291145353cf5a29605aaa70523464ca047fa
first = NULL; first = NULL;
} }
@ -89,10 +58,6 @@ struct car* clear_train(struct car* first, const char* target){
while(temp != NULL){ while(temp != NULL){
next = temp->next; next = temp->next;
<<<<<<< HEAD
if(!strcmp(temp->value, target))
free(temp);
=======
if(!strcmp(temp->value, target)) { if(!strcmp(temp->value, target)) {
if(temp == first) { if(temp == first) {
free(first); free(first);
@ -101,7 +66,6 @@ struct car* clear_train(struct car* first, const char* target){
else else
free(temp); free(temp);
} }
>>>>>>> 2033291145353cf5a29605aaa70523464ca047fa
temp = next; temp = next;
if(!first) if(!first)
first = temp; first = temp;