forked from Alexey/DAS_2024_1
30 lines
879 B
Python
30 lines
879 B
Python
|
import os
|
||
|
|
||
|
def find_max_number(file_path):
|
||
|
max_number = float('-inf')
|
||
|
with open(file_path, "r") as f:
|
||
|
# Читаем все строки из файла
|
||
|
content = f.read()
|
||
|
# Разделяем строки по пробелам для получения списка чисел
|
||
|
numbers = map(int, content.split())
|
||
|
for number in numbers:
|
||
|
if number > max_number:
|
||
|
max_number = number
|
||
|
return max_number
|
||
|
|
||
|
def save_result(result, file_path):
|
||
|
with open(file_path, "w") as f:
|
||
|
f.write(str(result))
|
||
|
|
||
|
def print_result(result):
|
||
|
print("Квадрат наибольшего числа:", result)
|
||
|
|
||
|
file_path = "/var/result/data.txt"
|
||
|
|
||
|
max_number = find_max_number(file_path)
|
||
|
|
||
|
result_file_path = "/var/result/result.txt"
|
||
|
save_result(max_number ** 2, result_file_path)
|
||
|
|
||
|
print_result(max_number ** 2)
|