110,534
社区成员
发帖
与我相关
我的任务
分享
using System;
namespace ConsoleApplication4
{
class Program
{
static string[] Items = new string[] { "A", "B", "C", "D", "E" };
static void Main(string[] args)
{
int selectCount = 2;
Select(0, selectCount, string.Empty);
}
static void Select(int currentIndex, int remain, string currentSelect)
{
if (remain == 0)
{
Console.WriteLine(currentSelect);
return;
}
if (Items.Length - currentIndex < remain)
return;
Select(currentIndex + 1, remain - 1, currentSelect + Items[currentIndex]);
Select(currentIndex + 1, remain, currentSelect);
}
}
}