Aktualizovat du5/program.c

This commit is contained in:
Tomáš Vlček 2026-04-15 11:01:25 +00:00
parent 5c5ad64990
commit a15d536937

View File

@ -20,6 +20,7 @@ int lineCount = 0;
int indexLine = 0;
int nodeCount = 0;
int answerCount = 0;
bool isTreeBroken = false;
//pomocna konstanta
const int invalidIndex = -1;
@ -30,6 +31,7 @@ int buildATree()
{
if (indexLine >= lineCount)
{
isTreeBroken = true;
return -1;
}
@ -57,6 +59,12 @@ int buildATree()
tree[current].yes = buildATree(); // 'a'
tree[current].no = buildATree(); // 'n'
//kontrola - jedna otazka musii mat dve deti (AK NIE vyhodi chybu)
if (tree[current].yes == -1 || tree[current].no == -1)
{
treeIsBroken = true;
}
return current;
}