# 求助一个排列组合的算法问题(在线等,立结贴)

jackylincn 2012-09-25 05:19:46

0102030405060708,010203040506070809.....1110090807060504,总计有11*10*9*8*7*6*5*4/(1*2*3*4*5*6*7*8)=165种排列组合,求算法
...全文
121 4 打赏 收藏 转发到动态 举报

4 条回复

devmiao 2012-09-25
• 打赏
• 举报

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

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 . . .
jackylincn 2012-09-25
• 打赏
• 举报

[Quote=引用 2 楼 的回复:]
http://blog.csdn.net/happy09li/article/details/7715858
[/Quote]

• 打赏
• 举报

bdmh 2012-09-25
• 打赏
• 举报

109,901

• 近7日
• 近30日
• 至今