日期:2014-05-17 浏览次数:20544 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<int> source = new List<int>() { 1, 2, 2, 3, 4, 5 }; var query = source.Arrange().Where(x => x[2] != 4 && !string.Join("", x.ToArray()).Contains("35") && !string.Join("", x.ToArray()).Contains("53")); foreach (var item in query) { Console.WriteLine(string.Join(", ", item.ToArray())); } } } static class ArrangeHelper { private static List<List<int>> Arrange(int n) { var result = Enumerable.Range(0, n).Select(x => new List<int>() { x }).ToList(); while (result[0].Count < n) { result = result.SelectMany(x => Enumerable.Range(0, n).Except(x).Select(y => x.Concat(new List<int>() { y }).ToList())).ToList(); } return result; } public static IEnumerable<List<T>> Arrange<T>(this List<T> source) { return Arrange(source.Count).Select(x => x.Select(y => source[y]).ToList()); } } }
------解决方案--------------------
如果求数目
A66 / 2 - 60 - A55(5/6)
------解决方案--------------------
算错了 -A55(4/6)
头疼
------解决方案--------------------
回溯