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

24
labPython/lab4/MinMax27.py Executable file
View File

@@ -0,0 +1,24 @@
import random
nBit = int(input("Введите количество элементов N: "))
bitArray = [random.randint(0, 1) for _ in range(nBit)]
print(bitArray)
countLen = 0
countIndex = 0
bitMax = 0
bitMaxIndex = 0
for i in range(len(bitArray)):
if i < len(bitArray)-1:
if bitArray[i] == bitArray[(i+1)]:
countLen +=1
if countLen > bitMax:
bitMax = countLen
bitMaxIndex = (i+2) - bitMax
# countLen = 0
else:
countLen = 0
bitMax += 1
print(bitMax, bitMaxIndex)