From a15d5369379e5b8e31925609d81b391cba41273d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vl=C4=8Dek?= Date: Wed, 15 Apr 2026 11:01:25 +0000 Subject: [PATCH] Aktualizovat du5/program.c --- du5/program.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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; }