我现在有11个数字,我要任选其中的8个数字做排列组合,两两不相同,现在我要把这8个数字的排列组合全部列举出来,如
0102030405060708,010203040506070809.....1110090807060504,总计有11*10*9*8*7*6*5*4/(1*2*3*4*5*6*7*8)=165种排列组合,求算法
0102030405060708,010203040506070809.....1110090807060504,总计有11*10*9*8*7*6*5*4/(1*2*3*4*5*6*7*8)=165种排列组合,求算法
解决方案 »
- 关于c#的登录问题
- 如何比较多个PictureBox中的图片
- 如何修改使用ClickOnce在客户端生成的文件夹名称
- 如何等窗体完全显示后再做其它的事情
- SqlDataReader的奇怪问题
- DataGridViewComboBoxColumn 单击事件怎么定义
- 怎么将一blob字段内容上传下载到文件,高分在线等!!!
- 还是关于应用程序间通信的问题
- 怎么写一个DataGrid的CurrentRowIndexChanged事件?
- DataGrid 动态绑定 Dropdownlist 的问题 ,高手们帮帮忙,急!!! 谢谢
- 关于c#调用cmd互动的问题
- repeater控件内容排序,单击repeater控件的表头,按该表头字段的内容实现排序!在线等!
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication1
{
class Program
{ static void Main(string[] args)
{
foreach (string item in BeginCombo().Select(x => string.Join("", x.Select(y => y.ToString().PadLeft(2, '0')))))
Console.WriteLine(item);
} static IEnumerable<IEnumerable<int>> BeginCombo()
{
return Enumerable.Range(1, 11).SelectMany(x => Combo(new int[] { x }, Enumerable.Range(1, 11).Where(y => y > x)));
} static IEnumerable<IEnumerable<int>> Combo(IEnumerable<int> current, IEnumerable<int> element)
{
if (current.Count() < 8)
return element.SelectMany(x => Combo(current.Concat(new int[] { x }), Enumerable.Range(1, 11).Where(y => y > x)));
else
return new List<IEnumerable<int>> { current };
}
}
}0102030405060708
0102030405060709
0102030405060710
0102030405060711
0102030405060809
0102030405060810
0102030405060811
0102030405060910
0102030405060911
0102030405061011
0102030405070809
0102030405070810
0102030405070811
0102030405070910
0102030405070911
0102030405071011
0102030405080910
0102030405080911
0102030405081011
0102030405091011
0102030406070809
0102030406070810
0102030406070811
0102030406070910
0102030406070911
0102030406071011
0102030406080910
0102030406080911
0102030406081011
0102030406091011
0102030407080910
0102030407080911
0102030407081011
0102030407091011
0102030408091011
0102030506070809
0102030506070810
0102030506070811
0102030506070910
0102030506070911
0102030506071011
0102030506080910
0102030506080911
0102030506081011
0102030506091011
0102030507080910
0102030507080911
0102030507081011
0102030507091011
0102030508091011
0102030607080910
0102030607080911
0102030607081011
0102030607091011
0102030608091011
0102030708091011
0102040506070809
0102040506070810
0102040506070811
0102040506070910
0102040506070911
0102040506071011
0102040506080910
0102040506080911
0102040506081011
0102040506091011
0102040507080910
0102040507080911
0102040507081011
0102040507091011
0102040508091011
0102040607080910
0102040607080911
0102040607081011
0102040607091011
0102040608091011
0102040708091011
0102050607080910
0102050607080911
0102050607081011
0102050607091011
0102050608091011
0102050708091011
0102060708091011
0103040506070809
0103040506070810
0103040506070811
0103040506070910
0103040506070911
0103040506071011
0103040506080910
0103040506080911
0103040506081011
0103040506091011
0103040507080910
0103040507080911
0103040507081011
0103040507091011
0103040508091011
0103040607080910
0103040607080911
0103040607081011
0103040607091011
0103040608091011
0103040708091011
0103050607080910
0103050607080911
0103050607081011
0103050607091011
0103050608091011
0103050708091011
0103060708091011
0104050607080910
0104050607080911
0104050607081011
0104050607091011
0104050608091011
0104050708091011
0104060708091011
0105060708091011
0203040506070809
0203040506070810
0203040506070811
0203040506070910
0203040506070911
0203040506071011
0203040506080910
0203040506080911
0203040506081011
0203040506091011
0203040507080910
0203040507080911
0203040507081011
0203040507091011
0203040508091011
0203040607080910
0203040607080911
0203040607081011
0203040607091011
0203040608091011
0203040708091011
0203050607080910
0203050607080911
0203050607081011
0203050607091011
0203050608091011
0203050708091011
0203060708091011
0204050607080910
0204050607080911
0204050607081011
0204050607091011
0204050608091011
0204050708091011
0204060708091011
0205060708091011
0304050607080910
0304050607080911
0304050607081011
0304050607091011
0304050608091011
0304050708091011
0304060708091011
0305060708091011
0405060708091011
Press any key to continue . . .