distributed-computing/tasks/mutriskov-ds/lab_2/worker-2/Program.cs

24 lines
553 B
C#
Raw Normal View History

2024-01-06 20:18:32 +04:00
using System.Text;
int min = int.MaxValue;
int[] numbers = File.ReadAllLines("/var/data/data.txt").Select(x=> int.Parse(x)).ToArray();
foreach(var number in numbers)
{
if (number < min)
{
min = number;
}
}
string result = Convert.ToString(Math.Pow(min, 3));
using (FileStream fstream1 = new FileStream("/var/result/result.txt", FileMode.OpenOrCreate))
{
fstream1.SetLength(0);
byte[] buffer1 = Encoding.Default.GetBytes(result);
await fstream1.WriteAsync(buffer1, 0, buffer1.Length);
}
Console.WriteLine(result);