Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- def generation():
- ''' Генерируется список чисел согласно условию '''
- global M, N
- N = randint(0, 10000)
- M = randint(-1000000, 1000000)
- for x in range(N):
- data.append(randint(-1000000, 1000000))
- # матрица записывается в файл
- f = open("in-5.txt", "w")
- f.write(str(data))
- f.close()
- data.clear()
- def openFileAndReadData():
- ''' Считывается файл с данными '''
- global M, N
- answer = 0
- with open("in-5.txt") as f:
- for line in f:
- data.append([int(x) for x in line.replace("[", "").replace("]", "").replace(",", "").split()])
- f.close()
- for array in data:
- for x in array:
- if x > M:
- answer += 1;
- print (f'N: {N}\nM: {M}\nanswer: {answer}')
- data = []
- generation()
- openFileAndReadData()
Add Comment
Please, Sign In to add comment