字符串组合和最小公倍数和最大公约数问题

  //例如输入字符串abc,则输出由字符a、b、c 所能排列出来的所有字符串
        public static void AllArray(string str, string str2 = "")
        {
            if (str == null)
                return;

            if (str == string.Empty)
                Console.WriteLine(str2);

            for (int i = 0; i < str.Length; i++)
            {

                AllArray(str.Remove(i, 1), str2 + str[i].ToString());

            }
        }


        public static void MinGong()
        {
            int temp1 = int.Parse(Console.ReadLine());
            int temp2 = int.Parse(Console.ReadLine());

            int n1 = Math.Max(temp1, temp2);
            int n2 = Math.Min(temp1, temp2);
            int Mul = n1 * n2;
            int min;
            int m;

            //最大公约数
            while (n2 != 0)
            {
                n1 = n1 > n2 ? n1 : n2;
                m = n1 % n2;
                n1 = n2;
                n2 = m;
            }
            min = Mul / n1;
            Console.WriteLine(n1);
            Console.WriteLine(min);
        }

原文地址:https://www.cnblogs.com/dasydong/p/3280954.html