From 0edab5145b9a2d3d5ccac29bc4d39c6e9c9a4e83 Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Tue, 10 Nov 2020 21:47:36 +0100 Subject: [PATCH] achhhhhhh --- cv6/a_station.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cv6/a_station.c b/cv6/a_station.c index 9796ce3..7f0529a 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -50,6 +50,22 @@ int select_track(struct station* station, const char* target){ } void add_target_capacity(struct station* station,const char* target, int capacity){ +int i = select_track(station,target); + struct car* slot = station->tracks[i]; + if(station->tracks[i]==NULL){ + struct car* newCar = malloc(sizeof(struct car)); + strcpy(newCar->value,target); + newCar->capacity=capacity; + newCar->next=slot; + station->tracks[i]=newCar; + } + while (slot!=NULL) + { + if(strcmp(slot->value,target)==0){ + slot->capacity +=capacity; + } + slot=slot->next; + } } int get_target_capacity(struct station* station,const char* target){