求M选N算法 十分急 求高手
求M选N算法 非常急 求高手
如题 C# 比如5选3
最后输出
123**
12*4*
12**5
1*34*
1*3*5
1**45
*234*
*23*5
*2*45
**345
------解决方案--------------------
如题 C# 比如5选3
最后输出
123**
12*4*
12**5
1*34*
1*3*5
1**45
*234*
*23*5
*2*45
**345
------解决方案--------------------
- C# code
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string s = "12345"; var query = from x in s from y in s where x != y select s.Replace(x, '*').Replace(y, '*'); foreach (var item in query) Console.WriteLine(item); } } }
------解决方案--------------------
- C# code
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string s = "12345"; var query = (from x in s from y in s where x != y orderby x + y descending select s.Replace(x, '*').Replace(y, '*')).Distinct(); foreach (var item in query) Console.WriteLine(item); } } }
------解决方案--------------------