CSharp · Console
using System;
using System.Linq;
public class Program
{
public static void Main()
{
double[] arr = { 2.11, 70.22, 15.67, 92.88, 105.91, 65.32, 40.25, 9.11, 22.09 };
int n;
Console.WriteLine("Enter the number of highest elements you want to extract from the array:");
while(!int.TryParse(Console.ReadLine(), out n))
{
Console.WriteLine("Enter the number of highest elements you want to extract from the array:");
}
var result = arr.OrderByDescending(x=>x).Take(n).ToArray();
foreach (var item in result)
{
Console.WriteLine(item);
}
}
}