distributed-computing/tasks/plaksina-av/lab_2/worker-2/Program.cs

35 lines
956 B
C#
Raw Permalink Normal View History

2023-10-12 02:40:26 +04:00
using System.ComponentModel.DataAnnotations;
using System;
using System.IO;
string inputFile = "/var/data/data.txt";
2023-10-12 02:40:26 +04:00
string resultFilePath = "/var/result/result.txt";
2023-10-12 02:40:26 +04:00
using (StreamWriter writer = new StreamWriter(resultFilePath, false))
{
int min = int.MaxValue;
using (StreamReader sr = new StreamReader(inputFile))
{
string line;
int i = 0;
while ((line = sr.ReadLine()) != null)
{
i++;
if (int.TryParse(line, out int value))
{
if (value < min)
{
min = value;
}
}
}
Console.WriteLine("Наименьшее число в файле: " + min.ToString());
}
double triplemin = Math.Pow(min, 3);
writer.WriteLine(triplemin.ToString());
Console.WriteLine("Файл второго приложения успешно создан: " + resultFilePath);
}