Aktualizovat du6/a_station.c

This commit is contained in:
Tomáš Vlček 2026-04-23 22:23:07 +00:00
parent ca67fe9fd4
commit 2ad320200e

View File

@ -44,7 +44,7 @@ int select_track(struct station* station, const char* target)
while (target[i] != '\0') {
// viacej 'human readable' verzia algorithmu.
//Pri hashovacich funkciach je zvykom pouzivat bitwise operator ('>>') na docielenie rovnakeho vysledku
//Pri hashovacich funkciach v programovani je zvykom pouzivat bitwise operator ('>>') na docielenie rovnakeho vysledku
hash_value = (hash_value * 33) + target[i];
i++;
}
@ -73,8 +73,8 @@ void add_target_capacity(struct station* station,const char* target, int capacit
//Poistka -> ak neexistuje novy zaznam, vyvtori ho
struct car* newCar = malloc(sizeof(struct car));
strncpy(newCar->value, target, lastPosIndex);
new_car->value[lastPosIndex] = '\0'; //null terminovanie..
new_car->capacity = capacity;
newCar->value[lastPosIndex] = '\0'; //null terminovanie..
newCar->capacity = capacity;
//vlozi na zaciatok tracku
new_car->next = station->tracks[index];
@ -88,7 +88,7 @@ int get_target_capacity(struct station* station,const char* target)
struct car* currentTracks = station->tracks[i];
while (currentTracks->next != NULL)
{
if (strcmp(currentTracks->value, target) == 0)
if (strcmp(currentTracks->value, target) != 0)
{
return currentTracks->capacity;
}