cv6
This commit is contained in:
		
							parent
							
								
									47b2d968ce
								
							
						
					
					
						commit
						08ae834f6c
					
				| @ -23,6 +23,24 @@ 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 index = select_track(station, target); | ||||||
|  |     struct car* current = station->tracks[index]; | ||||||
|  |      | ||||||
|  |     while (current) { | ||||||
|  |         if (strcmp(current->value, target) == 0) { | ||||||
|  |             current->capacity += capacity;  // Pridá kapacitu
 | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         current = current->next; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Ak ciel neexistuje, pridá novy zaznam do zoznamu
 | ||||||
|  |     struct car* new_car = (struct car*)malloc(sizeof(struct car)); | ||||||
|  |     strncpy(new_car->value, target, TARGET_SIZE - 1); | ||||||
|  |     new_car->value[TARGET_SIZE - 1] = '\0'; | ||||||
|  |     new_car->capacity = capacity; | ||||||
|  |     new_car->next = station->tracks[index]; | ||||||
|  |     station->tracks[index] = new_car; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int get_target_capacity(struct station* station,const char* target){ | int get_target_capacity(struct station* station,const char* target){ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user