Для нелюбящих указывать язык в задании предлагается решение на C# 7.3
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
int[] data = ReadIntSeq(8, "Enter values").ToArray();
Console.Write(string.Format("Minimal number that ends by 9 is {0}", data.MinBy(x => x % 10 == 9)));
}
public static IEnumerable<int> ReadIntSeq(int n, string promt = null)
{
if (promt != null)
Console.WriteLine(promt);
for (int i = 0; i < n; i++)
{
yield return int.Parse(Console.ReadLine());
}
}
}
public static class Extensions
{
public static T MinBy<T>(this IEnumerable<T> source, Func<T, bool> predicate) where T: IComparable
{
return source.Where(predicate).Min();
}
}
end.
Объяснение: