日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

组合 z

發布時間:2023/12/31 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 组合 z 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

輸入a?b?c?d?e以及它們對應的數字
比如
a-->1?2?3?
b-->2?3
c-->1
d-->3?4?5
e-->1?3?5
輸出a?b?c?d?e的可用組合,a?b?c?d?e不重復,如
a-->2
b-->3
c-->1
d-->4
e-->5

?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication1 {class Program{static void Main(string[] args){var dict = new Dictionary<char, List<int>>(){{ 'a', new List<int> { 1, 2, 3 } },{ 'b', new List<int> { 2, 3 } },{ 'c', new List<int> { 1 } },{ 'd', new List<int> { 3, 4, 5 } },{ 'e', new List<int> { 1, 3, 5 } }};foo(dict, new Dictionary<char, int>());}static void foo(Dictionary<char, List<int>> data, Dictionary<char, int> pre){if (data.Count == 0){Console.WriteLine("found:");foreach (var item in pre.OrderBy(x => x.Key))Console.WriteLine("{0} - {1}", item.Key, item.Value);return;}var first = data.OrderBy(x => x.Value.Count()).First();foreach (var item in first.Value){foo(data.OrderBy(x => x.Value.Count()).Skip(1).ToDictionary(x => x.Key, x => x.Value.Except(new int[] { item }).ToList()), pre.Cast<KeyValuePair<char, int>>().Concat(new KeyValuePair<char, int>[] { new KeyValuePair<char, int>(first.Key, item) }).ToDictionary(x => x.Key, x => x.Value));}}} }

?

總結

以上是生活随笔為你收集整理的组合 z的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。