From 449262923823a304b62d3623ff8849d5dfce0084 Mon Sep 17 00:00:00 2001 From: ov075wu Date: Wed, 12 Nov 2025 20:26:03 +0100 Subject: [PATCH] refresh --- du5/a_program.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/du5/a_program.c b/du5/a_program.c index 2a3a9ce..ef0ae43 100644 --- a/du5/a_program.c +++ b/du5/a_program.c @@ -19,9 +19,7 @@ int select_track(struct station* s, const char* target) { } void add_target_capacity(struct station* s, const char* target, int capacity) { - if (!s || !target) { - return; - } + if (!s || !target) return; int index = select_track(s, target); struct car* current = s->tracks[index]; @@ -52,23 +50,23 @@ void add_target_capacity(struct station* s, const char* target, int capacity) { prev->next = new_car; } -struct car* find_target(struct station* s, const char* target) { - if (!s || !target) return NULL; +int get_target_capacity(struct station* s, const char* target) { + if (!s || !target) return 0; int index = select_track(s, target); struct car* current = s->tracks[index]; while (current != NULL) { if (strcmp(current->value, target) == 0) { - return current; + return current->capacity; } current = current->next; } - return NULL; + return 0; } -int get_total_targets(struct station* s) { +int count_targets(struct station* s) { if (!s) return 0; int count = 0; @@ -82,7 +80,7 @@ int get_total_targets(struct station* s) { return count; } -int get_total_capacity(struct station* s) { +int count_capacity(struct station* s) { if (!s) return 0; int total = 0; @@ -96,22 +94,6 @@ int get_total_capacity(struct station* s) { return total; } -void print_station(struct station* s) { - if (!s) return; - - printf("station>>>\n"); - for (int i = 0; i < s->track_count; i++) { - struct car* current = s->tracks[i]; - printf("[%d]: ", i); - while (current != NULL) { - printf("%s (%d) -> ", current->value, current->capacity); - current = current->next; - } - printf("NULL\n"); - } - printf("<<