distributed-computing/tasks/mytarin_es/lab2/worker-2/Program.cs
2023-10-09 22:26:37 +03:00

32 lines
668 B
C#

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 itog = firstNumber * lastNumber;
using (StreamWriter writer = new StreamWriter("../var/result/result.txt"))
{
writer.WriteLine(itog);
}
Console.WriteLine("Программа 2 завершена");
Console.WriteLine("Результат: " + itog);