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') {
|
while (target[i] != '\0') {
|
||||||
// viacej 'human readable' verzia algorithmu.
|
// 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];
|
hash_value = (hash_value * 33) + target[i];
|
||||||
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
|
//Poistka -> ak neexistuje novy zaznam, vyvtori ho
|
||||||
struct car* newCar = malloc(sizeof(struct car));
|
struct car* newCar = malloc(sizeof(struct car));
|
||||||
strncpy(newCar->value, target, lastPosIndex);
|
strncpy(newCar->value, target, lastPosIndex);
|
||||||
new_car->value[lastPosIndex] = '\0'; //null terminovanie..
|
newCar->value[lastPosIndex] = '\0'; //null terminovanie..
|
||||||
new_car->capacity = capacity;
|
newCar->capacity = capacity;
|
||||||
|
|
||||||
//vlozi na zaciatok tracku
|
//vlozi na zaciatok tracku
|
||||||
new_car->next = station->tracks[index];
|
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];
|
struct car* currentTracks = station->tracks[i];
|
||||||
while (currentTracks->next != NULL)
|
while (currentTracks->next != NULL)
|
||||||
{
|
{
|
||||||
if (strcmp(currentTracks->value, target) == 0)
|
if (strcmp(currentTracks->value, target) != 0)
|
||||||
{
|
{
|
||||||
return currentTracks->capacity;
|
return currentTracks->capacity;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user