diff --git a/du5/program.c b/du5/program.c index 14b0599..7ca54db 100644 --- a/du5/program.c +++ b/du5/program.c @@ -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; }