2023-10-18 10:45:47 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
string[] numbers;
|
2023-12-02 10:45:25 +04:00
|
|
|
|
using (FileStream fstream = File.OpenRead("/var/result/data.txt"))
|
2023-10-18 10:45:47 +04:00
|
|
|
|
{
|
|
|
|
|
byte[] buffer = new byte[fstream.Length];
|
|
|
|
|
await fstream.ReadAsync(buffer, 0, buffer.Length);
|
|
|
|
|
string text = Encoding.Default.GetString(buffer);
|
|
|
|
|
text = text.Replace("\r\n", ";");
|
|
|
|
|
numbers = text.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int maxNumber = int.MinValue;
|
|
|
|
|
foreach (var number in numbers)
|
|
|
|
|
{
|
|
|
|
|
int currentNumber = Convert.ToInt32(number);
|
|
|
|
|
if (currentNumber > maxNumber)
|
|
|
|
|
{
|
|
|
|
|
maxNumber = currentNumber;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int maxNumberSquared = maxNumber * maxNumber;
|
|
|
|
|
|
2023-12-02 10:45:25 +04:00
|
|
|
|
using (FileStream fstream = new FileStream("/var/result/result.txt", FileMode.OpenOrCreate))
|
2023-10-18 10:45:47 +04:00
|
|
|
|
{
|
|
|
|
|
byte[] buffer = Encoding.Default.GetBytes(maxNumberSquared.ToString());
|
|
|
|
|
await fstream.WriteAsync(buffer, 0, buffer.Length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Максимальное число во входных данных: " + maxNumber);
|
|
|
|
|
Console.WriteLine("Квадрат максимального числа: " + maxNumberSquared);
|