24 lines
720 B
C#
24 lines
720 B
C#
|
var dir = new DirectoryInfo("../var/data");
|
|||
|
var fileName = dir.GetFiles().First().Name;
|
|||
|
string[] numbers = File.ReadAllLines("/var/data/" + fileName);
|
|||
|
long k = 0;
|
|||
|
long min = long.MaxValue;
|
|||
|
foreach (var numberStr in numbers)
|
|||
|
{
|
|||
|
if (!int.TryParse(numberStr, out int number))
|
|||
|
continue;
|
|||
|
if (number < min)
|
|||
|
min = number;
|
|||
|
}
|
|||
|
|
|||
|
foreach (var numberStr in numbers)
|
|||
|
{
|
|||
|
if (!int.TryParse(numberStr, out int number))
|
|||
|
continue;
|
|||
|
if (min == number)
|
|||
|
k++;
|
|||
|
}
|
|||
|
|
|||
|
File.WriteAllText("/var/result/result.txt", k.ToString());
|
|||
|
Console.WriteLine("Сервис 2 отработал успешно!");
|
|||
|
Console.WriteLine($"Наименьшее число:= {min} , число вхождений:= {k}");
|