#Python
#ответ B:
n = 1
num = []
while n != 0:
n = int(input("Введите число : "))
if n != 0:
num.append(n)
num3 = []
for n in num:
if int(n) % 3 == 0:
num3.append(n)
print("Макс :", max(num3), " Мин :", min(num3))
#ответ C:
if n != 0 and len(str(n)) == 2:
num6 = []
if int(n) % 10 == 6:
num6.append(n)
if num6 == True:
print("Макс : ", max(num6))
else:
print("Нет такого число!")
Объяснение:
inFile = open('input.txt', 'r', encoding='utf8')
outFile = open('output.txt', 'w', encoding='utf8')
score = []
i = 0
nstr = 1
for line in inFile:
if nstr == 1:
k = int(line)
line1 = line.split()
sc3 = int(line1[-1])
sc2 = int(line1[-2])
sc1 = int(line1[-3])
if sc1 >= 40 and sc2 >= 40 and sc3 >= 40:
score.append(sc1 + sc2 + sc3)
i += 1
nstr += 1
inFile.close()
if k >= i:
print(0, file=outFile)
score.sort(reverse=True)
if score[k-1] > score[k]:
print(score[k-1], file=outFile)
ans = ''
for ii in score[k-1::-1]:
if score[k-1] < ii and ans == '':
ans = ii
if ans == '':
ans = 1
print(ans, file=outFile)
outFile.close()
#Python
#ответ B:
n = 1
num = []
while n != 0:
n = int(input("Введите число : "))
if n != 0:
num.append(n)
num3 = []
for n in num:
if int(n) % 3 == 0:
num3.append(n)
print("Макс :", max(num3), " Мин :", min(num3))
#ответ C:
n = 1
num = []
while n != 0:
n = int(input("Введите число : "))
if n != 0 and len(str(n)) == 2:
num.append(n)
num6 = []
for n in num:
if int(n) % 10 == 6:
num6.append(n)
if num6 == True:
print("Макс : ", max(num6))
else:
print("Нет такого число!")
Объяснение:
inFile = open('input.txt', 'r', encoding='utf8')
outFile = open('output.txt', 'w', encoding='utf8')
score = []
i = 0
nstr = 1
for line in inFile:
if nstr == 1:
k = int(line)
else:
line1 = line.split()
sc3 = int(line1[-1])
sc2 = int(line1[-2])
sc1 = int(line1[-3])
if sc1 >= 40 and sc2 >= 40 and sc3 >= 40:
score.append(sc1 + sc2 + sc3)
i += 1
nstr += 1
inFile.close()
if k >= i:
print(0, file=outFile)
else:
score.sort(reverse=True)
if score[k-1] > score[k]:
print(score[k-1], file=outFile)
else:
ans = ''
for ii in score[k-1::-1]:
if score[k-1] < ii and ans == '':
ans = ii
if ans == '':
ans = 1
print(ans, file=outFile)
outFile.close()