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

  • 相关阅读:
    vue中使用clipboard.js复制分本
    聊聊IOCP,聊聊异步编程
    dubbo RPC超时异常小结
    redis4.0 集群,jedis客户端连接配置
    Centos7 Zookeeper
    阿里云Centos 7.4 mssql-server
    Redis4.0 Cluster — Centos7
    Elasticsearch学习笔记 一
    Centos7安装ES 和 Docker搭建ES
    使用Docker快速创建.Net Core2.0 Nginx负载均衡节点
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/1792445.html
Copyright © 2011-2022 走看看