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

  • 相关阅读:
    写在彻底转向有道云笔记一个月之后
    KMP算法实现
    有道云笔记 V.S. 为知笔记
    卸载印象笔记,跟印象笔记说拜拜
    ExpandRegion for Sublime Text:快速选择文本
    Linux cat命令详解
    Vim安装插件
    Vim与正则表达式
    还没供暖
    在Linux命令行中设置并使用代理服务器
  • 原文地址:https://www.cnblogs.com/dasydong/p/3280954.html
Copyright © 2011-2022 走看看