最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#組合函數(shù)的使用詳解

 更新時(shí)間:2013年06月09日 09:49:41   作者:  
本篇文章是對C#中的組合函數(shù)的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
如下所示:
復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{

    class Class1
    {
        static string[] str = { "A", "B", "C", "D", "E" };
        static void Main()
        {
            Dictionary<string, int> dic = new Dictionary<string, int>();
            //將數(shù)組元素添加到dic
            for (int i = 0; i < str.Length; i++)
            {
                dic.Add(str[i], i);
            }
            GetDic(dic);
            Console.ReadLine();
        }
        static void GetDic(Dictionary<string, int> dd)
        {
            Dictionary<string, int> dic = new Dictionary<string, int>();
            //主要是抓住AB,AC,AD,AE,然后就是開始從 BC,BD這樣的原理用dd中的鍵與數(shù)組的中對應(yīng)索引比dd中的value大進(jìn)行組合
            foreach (KeyValuePair<string, int> kk in dd)
            {
                for (int i = kk.Value + 1; i < str.Length; i++)
                {
                    Console.WriteLine(kk.Key + str[i]);
                    dic.Add(kk.Key + str[i], i);
                }
            }
            //遞歸
            if (dic.Count > 0) GetDic(dic);
        }
    }

}
結(jié)果
AB
AC
AD
AE
BC
BD
BE
CD
CE
DE
ABC
ABD
ABE
ACD
ACE
ADE
BCD
BCE
BDE
CDE
ABCD
ABCE
ABDE
ACDE
BCDE
ABCDE

相關(guān)文章

最新評論

周口市| 霸州市| 东宁县| 青岛市| 新余市| 岳阳县| 偃师市| 四平市| 师宗县| 金川县| 石城县| 武威市| 涞水县| 麟游县| 新泰市| 准格尔旗| 农安县| 泊头市| 凭祥市| 杂多县| 汽车| 云阳县| 恩施市| 丹江口市| 宁国市| 武冈市| 灵川县| 邢台县| 大同市| 宣城市| 乌鲁木齐县| 田阳县| 武穴市| 松阳县| 安义县| 裕民县| 安吉县| 永昌县| 玉门市| 新绛县| 万荣县|