using System; using System.Linq; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static IEnumerable> SelectNElements(int[] arr, int n) { IEnumerable> result = arr.Select(x => new List() { x }); for (int i = 1; i < n; i++) result = result.SelectMany(x => arr.Where(y => y > x.Max()), (x, y) => x.Concat(new int[] { y })); return result; } static void Main(string[] args) { int[] arr = { 1, 2, 3, 4 }; for (int i = 1; i <= arr.Length; i++) { var result = SelectNElements(arr, i); foreach (var item in result) { foreach (int x in item) Console.Write(x + " "); Console.WriteLine(); } } } } }