求在C#从M个数中取N个的所有组合算法,无重复 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20090217/21/f41ed9f6-f929-451c-a5c9-80d2e408422a.html?56197 以前为了追求效率都是自己模拟栈,现在还是化繁为简,直接用递归了,代码简单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); } }} 求win7访问system32文件夹权限解决方案 急急急,在c#中如何赋值给鼠标的滚轮??? lucene.net可以实现sql 里面in的效果吗??? C# int 和static int的区别是什么? C# combobox 如何下拉出 datagridview Winform窗体及其上的控件属性设置的问题 怎么使用radio来控制text显示隐藏 如何给ListBox中的项加上tip?急。。。 安装windows服务时出错 以上补充程序: 一个VS2008中TFS的问题
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);
}
}
}