This commit is contained in:
Vadym Afanasiev 2026-11-06 10:43:33 +00:00
parent 6937996645
commit 5adaba293f

View File

@ -7,15 +7,20 @@ class Node:
self.left = left
self.right = right
def main():
print("Expert zo zoo to vie.")
input_data = sys.stdin.read()
if not input_data:
print("Chybna databaza")
return
lines = input_data.splitlines()
if not lines:
print("Chybna databaza")
return
q_counter = 0
a_counter = 0
idx = 0
@ -24,16 +29,15 @@ def main():
nonlocal idx, q_counter, a_counter
if idx >= len(lines):
return None
line = lines[idx]
idx = idx + 1
line = lines[idx]
idx += 1
if line == "":
return None
if line.endswith('?'):
q_counter = q_counter + 1
q_counter += 1
left = parse_tree()
if left is None:
return None
@ -42,34 +46,39 @@ def main():
return None
return Node(line, left, right)
else:
a_counter = a_counter + 1
a_counter += 1
return Node(line)
root = parse_tree()
if root is None or idx >= len(lines) or lines[idx] != "":
print("Chybna databaza")
return
print(f"Pocet otazok: {q_counter}")
print(f"Pocet odpovedi: {a_counter}")
print("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.")
idx += 1
idx += 1
current = root
while True:
print(current.text)
if not current.text.endswith('?'):
print("Koniec")
break
#koniec vstup
if idx >= len(lines):
print("Koniec vstupu")
break
choice = lines[idx]
idx = idx + 1
idx += 1
if choice == 'a':
current = current.left
@ -79,5 +88,6 @@ def main():
print("Nerozumiem")
break
if __name__ == '__main__':
main()