zoukankan      html  css  js  c++  java
  • C#组合算法

      static string[] m_Data = { "A", "B", "C", "D", "E" };
            static void Main(string[] args)
            {
                Dictionary<string, int> dic = new Dictionary<string, int>();
                for (int i = 0; i < m_Data.Length; i++)
                {
                    Console.WriteLine(m_Data[i]);//如果不需要打印单元素的组合,将此句注释掉
                    dic.Add(m_Data[i], i);
                }
                GetString(dic);
                Console.ReadLine();
            }
            static void GetString(Dictionary<string, int> dd)
            {
                Dictionary<string, int> dic = new Dictionary<string, int>();
                foreach (KeyValuePair<string, int> kv in dd)
                {
                    for (int i = kv.Value + 1; i < m_Data.Length; i++)
                    {
                        //Console.WriteLine(kv.Key + " " + kv.Value + " " + i);
                        Console.WriteLine(kv.Key + m_Data[i]);
                        dic.Add(kv.Key + m_Data[i], i);
                    }
                }
                //Console.WriteLine(dic.Count);
                if (dic.Count > 0) GetString(dic);
            }

  • 相关阅读:
    【题解】【HAOI2011】Problem b
    【题解】完全平方数
    sqoop安装
    hive安装
    hbase分布式安装
    zookeeper分布式安装
    hadoop分布式安装
    zabbix proxy安装及使用
    web数据存储
    js格式
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/1792445.html
Copyright © 2011-2022 走看看