35 lines
879 B
C#
35 lines
879 B
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
class Program
|
|
{
|
|
static void Main()
|
|
{
|
|
const string inputFile = "/var/result/data.txt";
|
|
const string outputFile = "/var/result/result.txt";
|
|
|
|
try
|
|
{
|
|
var lines = File.ReadAllLines(inputFile).Select(int.Parse).ToArray();
|
|
|
|
if (lines.Length >= 2)
|
|
{
|
|
int result = lines.First() * lines.Last();
|
|
|
|
File.WriteAllText(outputFile, result.ToString());
|
|
|
|
Console.WriteLine($"Произведение: {result}");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Недостаточно данных в файле для вычисления.");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Ошибка: {ex.Message}");
|
|
}
|
|
}
|
|
}
|