Initializacia

This commit is contained in:
Kozar 2024-11-08 13:58:56 +00:00
parent a177886136
commit 2f4bf820c1

View File

@ -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;
}