This commit is contained in:
Filip Chochol 2026-04-08 16:14:38 +02:00
parent 670e8d79b2
commit 7848af3fe6

View File

@ -22,7 +22,7 @@ struct strom* nacitaj_strom() {
struct strom* uzol = calloc(1, sizeof(struct strom)); struct strom* uzol = calloc(1, sizeof(struct strom));
memcpy(uzol->hodnota, buffer, SIZE); memcpy(uzol->hodnota, buffer, SIZE);
if (buffer[0] == '*') { if (buffer[0] != '*') {
uzol->ano = nacitaj_strom(); uzol->ano = nacitaj_strom();
uzol->nie = nacitaj_strom(); uzol->nie = nacitaj_strom();
} }
@ -39,7 +39,7 @@ void znic_strom(struct strom* uzol) {
int spocitaj_listy(struct strom* uzol) { int spocitaj_listy(struct strom* uzol) {
if (uzol == NULL) return 0; if (uzol == NULL) return 0;
if (uzol->ano == NULL || uzol->nie == NULL) return 1; if (uzol->ano == NULL && uzol->nie == NULL) return 0;
return spocitaj_listy(uzol->ano) + spocitaj_listy(uzol->nie); return spocitaj_listy(uzol->ano) + spocitaj_listy(uzol->nie);
} }
@ -61,9 +61,9 @@ void spusti_system(struct strom* uzol) {
} }
if (odpoved[0] == 'a') { if (odpoved[0] == 'a') {
spusti_system(uzol->ano);
} else if (odpoved[0] == 'n') {
spusti_system(uzol->nie); spusti_system(uzol->nie);
} else if (odpoved[0] == 'n') {
spusti_system(uzol->ano);
} else { } else {
printf("Chybny vstup.\n"); printf("Chybny vstup.\n");
} }