Fixing adding
This commit is contained in:
parent
44c9a7a188
commit
39b29d3131
@ -58,42 +58,37 @@ void add_target_capacity(struct station* station,const char* target, int capacit
|
||||
|
||||
|
||||
int get_target_capacity(struct station* station,const char* target){
|
||||
struct car* ptr = *station->tracks;
|
||||
while (ptr)
|
||||
{ if(strcmp(ptr->value, target) == 0){
|
||||
return ptr->capacity;
|
||||
|
||||
}
|
||||
ptr = ptr->next;
|
||||
|
||||
|
||||
int res = select_track(station, target);
|
||||
struct car** ptr = &station->tracks[res];
|
||||
struct car* head = *ptr;
|
||||
if(head){
|
||||
return head->capacity;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count_targets(struct station* station){
|
||||
int count = 0;
|
||||
if(*station->tracks == NULL || station == NULL){
|
||||
if(station == NULL || station->tracks == NULL){
|
||||
return 0;
|
||||
}
|
||||
struct car* ptr = *station->tracks;
|
||||
while (ptr)
|
||||
{
|
||||
count++;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
return count;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int count_capacity(struct station* station){
|
||||
int res = 0;
|
||||
struct car* ptr = *station->tracks;
|
||||
while (ptr){
|
||||
res += ptr->capacity;
|
||||
ptr = ptr->next;
|
||||
if(station == NULL || station->tracks == NULL){
|
||||
return 0;
|
||||
}
|
||||
int total = 0;
|
||||
for(int i = 0; i<station->track_count; i++){
|
||||
struct car* ptr = station->tracks[i];
|
||||
while(ptr){
|
||||
total += ptr->capacity;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
}
|
||||
return res;
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user