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

  • 相关阅读:
    【硬件】交换机与路由器概述
    【网络】IP地址,子网掩码,网段表示法,默认网关,DNS服务器详解
    【网络】网桥
    【归档】Mysql大表归档
    【锁】Innodb锁
    【磁盘】顺序IO比随机IO快
    【硬盘】RAID卡
    【基础】占用空间大小(数据页、线程)
    【SQL】ON DUPLICATE KEY UPDATE
    【基础】Hint控制语句执行
  • 原文地址:https://www.cnblogs.com/dasydong/p/3280954.html
Copyright © 2011-2022 走看看