Update u7/zootechnik.py
This commit is contained in:
parent
079cf1651c
commit
ce27e2a8ee
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, text):
|
||||||
|
self.text = text
|
||||||
|
self.left = None
|
||||||
|
self.right = None
|
||||||
|
|
||||||
|
lines = sys.stdin.read().split("\n")
|
||||||
|
if lines[-1] == "":
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lines = []
|
||||||
|
while true;
|
||||||
|
line = input()
|
||||||
|
if line == "";
|
||||||
|
break;
|
||||||
|
lines.append(line);
|
||||||
|
print("Expert zo zoo to vie.")
|
||||||
|
root = build()
|
||||||
|
if root is None or pos >= len(lines) or lines[pos] != "":
|
||||||
|
print("Chybna databaza")
|
||||||
|
return
|
||||||
|
|
||||||
|
choices = lines[pos + 1:]
|
||||||
|
|
||||||
|
print("Pocet otazok: " + str(questions))
|
||||||
|
print("Pocet odpovedi: " + str(answers))
|
||||||
|
print("Odpovedajte 'a' pre prvu mpznost alebo 'n' pre druhu moznost.")
|
||||||
|
|
||||||
|
node = root
|
||||||
|
print(node.text)
|
||||||
|
i = 0
|
||||||
|
while node.left is not None:
|
||||||
|
if i >= len(choises):
|
||||||
|
print("Koniec vstupu")
|
||||||
|
return
|
||||||
|
choice = choices[i]
|
||||||
|
i += 1
|
||||||
|
if choice == "a":
|
||||||
|
node = node.left
|
||||||
|
elif choice == 'n':
|
||||||
|
node = node.right
|
||||||
|
else:
|
||||||
|
print("Nerozumiem")
|
||||||
|
return
|
||||||
|
print(node.text)
|
||||||
|
print("Koniec")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue
Block a user