Initializacia
This commit is contained in:
parent
a177886136
commit
2f4bf820c1
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user