zoukankan      html  css  js  c++  java
  • 字符串组合和最小公倍数和最大公约数问题

      //例如输入字符串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);
            }

  • 相关阅读:
    【IDEA】转大小写快速操作
    【WSDL】WebService描述语言的实践
    【WEB】URL文件
    【BatchProgram】工作用的小工具
    【Java】自制查找工具
    【DataBase】SQL优化问题
    【IDEA】DEBUG调试问题
    【DataBase】XueSQL Training
    【SVN】文件解锁
    【DataBase】SQL45 Training 45题训练
  • 原文地址:https://www.cnblogs.com/dasydong/p/3280954.html
Copyright © 2011-2022 走看看