diff --git a/du5/program.c b/du5/program.c index 243358a..42dd852 100644 --- a/du5/program.c +++ b/du5/program.c @@ -22,7 +22,7 @@ struct strom* nacitaj_strom() { struct strom* uzol = calloc(1, sizeof(struct strom)); memcpy(uzol->hodnota, buffer, SIZE); - if (buffer[0] == '*') { + if (buffer[0] != '*') { uzol->ano = nacitaj_strom(); uzol->nie = nacitaj_strom(); } @@ -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 1; + if (uzol->ano == NULL && uzol->nie == NULL) return 0; return spocitaj_listy(uzol->ano) + spocitaj_listy(uzol->nie); } @@ -61,9 +61,9 @@ void spusti_system(struct strom* uzol) { } if (odpoved[0] == 'a') { - spusti_system(uzol->ano); - } else if (odpoved[0] == 'n') { spusti_system(uzol->nie); + } else if (odpoved[0] == 'n') { + spusti_system(uzol->ano); } else { printf("Chybny vstup.\n"); }