111,074
社区成员




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n = 3;
string[] are = { "1", "2", "3", "4", "5", "6" };
var result = are.Select(x => new string[] { x });
for (int i = 0; i < n - 1; i++)
{
result = result.SelectMany(x => are.Where(y => y.CompareTo(x.First()) < 0).Select(y => new string[] { y }.Concat(x).ToArray()));
}
foreach (var item in result)
{
Console.WriteLine(string.Join(", ", item));
}
}
}
}
1, 2, 3
1, 2, 4
1, 3, 4
2, 3, 4
1, 2, 5
1, 3, 5
2, 3, 5
1, 4, 5
2, 4, 5
3, 4, 5
1, 2, 6
1, 3, 6
2, 3, 6
1, 4, 6
2, 4, 6
3, 4, 6
1, 5, 6
2, 5, 6
3, 5, 6
4, 5, 6
Press any key to continue . . .