distributed-computing/tasks/gorbyleva-ai/lab_2/worker-2/Program.cs

35 lines
900 B
C#
Raw Permalink Normal View History

using System.ComponentModel.DataAnnotations;
using System;
using System.IO;
string inputFile = "/var/data/data.txt";
string resultFilePath = "/var/result/result.txt";
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);
}