• C# 组合算法


     private static void perm(int[] list, int i, int n)
            {
                int j;

                if (i == n)
                {
                    for (int m = 0; m < list.GetUpperBound(0) + 1; m++)
                    {
                        Console.Write(list[m]);
                    }
                    Console.WriteLine(" ");

                }
                else
                {
                    for (j = i; j <= n; j++)
                    {
                        SWAP(ref list[i], ref list[j]);
                        perm(list, i + 1, n);
                        SWAP(ref list[i], ref list[j]);//数组一定要复原!!!!!
                    }
                }
            }
            private static void SWAP(ref int a, ref int b)
            {
                int c = a;
                a = b;
                b = c;
            }

  • 相关阅读:
    6000?
    基本把“主页大巴”做完了
    myDesk
    挂出了
    如何在网页中添加flash文件
    oracle的SQl语句
    打开PHP 提示下载
    实时计字数提醒的文本框
    wampserver无法打开http://localhost
    “ASP.adduser_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写
  • 原文地址:https://www.cnblogs.com/cxlings/p/2799813.html
Copyright © 2020-2023  润新知