distributed-computing/tasks/ostrovskaya-sf/lab_2/worker-2/Program.cs
Софья Островская c680a6e51d laba done
2023-10-10 16:55:06 +04:00

34 lines
738 B
C#

using System;
using System.IO;
string[] lines = File.ReadAllLines("../var/data/data.txt");
int firstNumber = 0;
int lastNumber = 0;
foreach (string line in lines)
{
if (int.TryParse(line, out int number))
{
firstNumber = number;
break;
}
}
for (int i = lines.Length - 1; i >= 0; i--)
{
if (int.TryParse(lines[i], out int number))
{
lastNumber = number;
break;
}
}
int multiplication = firstNumber * lastNumber;
using (StreamWriter writer = new StreamWriter("../var/result/result.txt"))
{
writer.WriteLine(multiplication);
}
Console.WriteLine("Произведение успешно записано в файл! Результат: " + multiplication);