Aktualizovat du5/program.c
This commit is contained in:
parent
5c5ad64990
commit
a15d536937
@ -20,6 +20,7 @@ int lineCount = 0;
|
|||||||
int indexLine = 0;
|
int indexLine = 0;
|
||||||
int nodeCount = 0;
|
int nodeCount = 0;
|
||||||
int answerCount = 0;
|
int answerCount = 0;
|
||||||
|
bool isTreeBroken = false;
|
||||||
|
|
||||||
//pomocna konstanta
|
//pomocna konstanta
|
||||||
const int invalidIndex = -1;
|
const int invalidIndex = -1;
|
||||||
@ -30,6 +31,7 @@ int buildATree()
|
|||||||
{
|
{
|
||||||
if (indexLine >= lineCount)
|
if (indexLine >= lineCount)
|
||||||
{
|
{
|
||||||
|
isTreeBroken = true;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +59,12 @@ int buildATree()
|
|||||||
tree[current].yes = buildATree(); // 'a'
|
tree[current].yes = buildATree(); // 'a'
|
||||||
tree[current].no = buildATree(); // 'n'
|
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;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user