标签:
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("请输入一个数:"); int num1 = int.Parse(Console.ReadLine()); Console.WriteLine("请输入另一个数:"); int num2 = int.Parse(Console.ReadLine()); int tmp; if (num1 < num2) { tmp = num1; num1 = num2; num2 = tmp; } int a = num1; int b = num2; while (b != 0) { tmp = a % b; a = b; b = tmp; } Console.WriteLine("{0}和{1}的最大公约数为:{2}",num1,num2,a); Console.WriteLine("{0}和{1}的最小公倍数为:{2}",num1,num2,num1*num2/a); } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/lucky51222/article/details/46685535