diff --git a/du5/a_station.c b/du5/a_station.c index 9a3bec1..e9d9a38 100644 --- a/du5/a_station.c +++ b/du5/a_station.c @@ -91,18 +91,28 @@ int get_target_capacity(struct station* station,const char* target){ } int count_targets(struct station* station){ - return 0; + int count = 0; + if(*station->tracks == NULL || station == NULL){ + return 0; + } + struct car* ptr = *station->tracks; + while (ptr) + { + count++; + ptr = ptr->next; + } + return count; + } int count_capacity(struct station* station){ int res = 0; struct car* ptr = *station->tracks; - while (ptr && ptr->next){ + while (ptr){ res += ptr->capacity; ptr = ptr->next; } - res += ptr->capacity; return res; }