This commit is contained in:
Filip Chochol 2026-04-08 16:17:49 +02:00
parent 7848af3fe6
commit 53cca3553b

View File

@ -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 0; if (uzol->ano == NULL && uzol->nie == NULL) return 1;
return spocitaj_listy(uzol->ano) + spocitaj_listy(uzol->nie); return spocitaj_listy(uzol->ano) + spocitaj_listy(uzol->nie);
} }
@ -61,17 +61,24 @@ void spusti_system(struct strom* uzol) {
} }
if (odpoved[0] == 'a') { if (odpoved[0] == 'a') {
spusti_system(uzol->nie);
} else if (odpoved[0] == 'n') {
spusti_system(uzol->ano); spusti_system(uzol->ano);
} else if (odpoved[0] == 'n') {
spusti_system(uzol->nie);
} else { } else {
printf("Chybny vstup.\n"); printf("Chybny vstup.\n");
} }
} }
int main() { int main() {
struct strom* koren = nacitaj_strom(); struct strom* koren = nacitaj_strom();
if (koren) {
printf("koren: %s", koren->hodnota);
printf("ano: %s", koren->ano ? koren->ano->hodnota : "NULL\n");
printf("nie: %s", koren->nie ? koren->nie->hodnota : "NULL\n");
}
if (koren == NULL) { if (koren == NULL) {
printf("Chyba: nepodarilo sa nacitat bazu pravidiel.\n"); printf("Chyba: nepodarilo sa nacitat bazu pravidiel.\n");
return 1; return 1;