Aktualizovat du6/a_station.c
This commit is contained in:
parent
ca67fe9fd4
commit
2ad320200e
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user