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);
            }

  • 相关阅读:
    跨域常见解决方案
    express-session的简单使用说明
    Spring Cloud中,如何解决Feign/Ribbon第一次请求失败的问题?
    继承父类的静态方法的加载顺序
    sql索引优化
    EXPLAIN 执行计划详解
    JVM总括二-垃圾回收:GC Roots、回收算法、回收器
    dubbo知识体系
    Spring bean的生命流程
    日志体系与异常处理
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/1792445.html
Copyright © 2011-2022 走看看