diff --git a/du5/program.c b/du5/program.c index 42dd852..7fc26f7 100644 --- a/du5/program.c +++ b/du5/program.c @@ -39,7 +39,7 @@ void znic_strom(struct strom* uzol) { int spocitaj_listy(struct strom* uzol) { 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); } @@ -61,17 +61,24 @@ void spusti_system(struct strom* uzol) { } if (odpoved[0] == 'a') { - spusti_system(uzol->nie); - } else if (odpoved[0] == 'n') { spusti_system(uzol->ano); + } else if (odpoved[0] == 'n') { + spusti_system(uzol->nie); } else { printf("Chybny vstup.\n"); } } int main() { + 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) { printf("Chyba: nepodarilo sa nacitat bazu pravidiel.\n"); return 1;