#include<iostream>
using namespace std;
int MAX_CF(int a, int b)
{
int temp = 0;
while (b != 0)
{
temp = a%b;
a = b;
b = temp;
}
return a;
}
int MIN_CD(int u, int v, int h)
{
return (u*v / h);
}
void main()
{
int num1, num2;
int cf, cd;
cout << "---------------求最大公约数和最小公倍数-----------" << endl;
cout << "请输入两个正整数: " << endl;
cin >> num1 >> num2;
cf = MAX_CF(num1, num2);
cout << "最大公约数: " << cf << endl;
cd = MIN_CD(num1, num2, cf);
cout << "最小公倍数: " << cd << endl;
}
最大公约数与最小公倍数
最新推荐文章于 2019-03-15 14:57:39 发布