cv6
This commit is contained in:
parent
641cf50bc0
commit
e62735dba4
@ -38,7 +38,25 @@ int select_track(struct station* station, const char* target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void add_target_capacity(struct station* station, const char* target, int capacity) {
|
void add_target_capacity(struct station* station, const char* target, int capacity) {
|
||||||
|
int track = select_track(station, target);
|
||||||
|
struct car* current = station->tracks[track];
|
||||||
|
|
||||||
|
while (current != NULL) {
|
||||||
|
if (strcmp(current->value, target) == 0) {
|
||||||
|
current->capacity += capacity;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct car* new_car = (struct car*)malloc(sizeof(struct car));
|
||||||
|
new_car->capacity = capacity;
|
||||||
|
strncpy(new_car->value, target, SIZE - 1);
|
||||||
|
new_car->value[SIZE - 1] = '\0';
|
||||||
|
new_car->next = station->tracks[track];
|
||||||
|
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){
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user