#include<iostream>
#include<windows.h>
using namespace std;
//求两个整数的最小公倍数
int Lower_Mul(int a, int b)
{
for (int i = 1; i <= a*b; i++)
{
if (i%a == 0 && i%b == 0)
return i;
}
}
//求两个整数的最大公约数
int _Min(int x, int y)
{
return x <y ? x : y;
}
int High_Divisor(int a, int b)
{
int c = _Min(a, b);
for (int i = c; i >=1; i--)
{
if (a%i ==0&&b%i==0)
return i;
}
}
int main()
{
cout << Lower_Mul(10, 20) << endl;//10
cout << High_Divisor(10, 20) << endl;//20
system("pause");
return 0;
}
#include<windows.h>
using namespace std;
//求两个整数的最小公倍数
int Lower_Mul(int a, int b)
{
for (int i = 1; i <= a*b; i++)
{
if (i%a == 0 && i%b == 0)
return i;
}
}
//求两个整数的最大公约数
int _Min(int x, int y)
{
return x <y ? x : y;
}
int High_Divisor(int a, int b)
{
int c = _Min(a, b);
for (int i = c; i >=1; i--)
{
if (a%i ==0&&b%i==0)
return i;
}
}
int main()
{
cout << Lower_Mul(10, 20) << endl;//10
cout << High_Divisor(10, 20) << endl;//20
system("pause");
return 0;
}