This commit is contained in:
2026-04-18 14:42:00 +05:00
commit ef77f101fa
96 changed files with 3134 additions and 0 deletions

43
labPython/lab16/task_3.py Normal file
View File

@@ -0,0 +1,43 @@
class Node:
def __init__(self, data):
self.data = data
self.next = None
def build(arr):
head = None
for x in reversed(arr):
node = Node(x)
node.next = head
head = node
return head
def find_second(head):
count = 0
while head:
if head.data % 6 == 0:
count += 1
if count == 2:
return head
head = head.next
return None
while True:
try:
print("\n1 - создать список")
print("2 - найти элемент")
print("0 - выход")
c = input(">> ")
if c == "1":
arr = list(map(int, input().split()))
head = build(arr)
elif c == "2":
res = find_second(head)
print(res.data if res else "nil")
elif c == "0":
break
except:
print("Ошибка")