From 2f4bf820c1657cb30626d282fd1907d4428dd2e7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Fri, 8 Nov 2024 13:58:56 +0000 Subject: [PATCH] Initializacia --- cv6/a_station.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index d104527..da0a69b 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -52,15 +52,41 @@ void add_target_capacity(struct station* station,const char* target, int capacit station->tracks[track] = new_car; } -int get_target_capacity(struct station* station,const char* target){ +int get_target_capacity(struct station* station, const char* target) { + int track = select_track(station, target); + struct car* current = station->tracks[track]; + + while (current) { + if (strcmp(current->value, target) == 0) { + return current->capacity; + } + current = current->next; + } + return 0; } -int count_targets(struct station* station){ - return 0; +int count_targets(struct station* station) { + int count = 0; + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + count++; + current = current->next; + } + } + return count; } -int count_capacity(struct station* station){ - return 0; +int count_capacity(struct station* station) { + int total_capacity = 0; + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + total_capacity += current->capacity; + current = current->next; + } + } + return total_capacity; }