写两个函数,分别求两个整数的最大公约数和最小公倍数,
用主函数调用这两个函数,并输出结果
两个整数由键盘输入。
#include<iostream>
using namespace std;
int yue(int x, int y)
{
int t, m;
if (x>y)
{
t = x;
x = y;
y = t;
}
while (x != 0)
{
m = y%x;
y = x;
x = m;
}
return y;
}
int bei(int x, int y)
{
int m;
m = x*y / yue(x, y);
return m;
}
int main()
{
int a, b, m, n;
cin >> a >> b;
m = yue(a, b);
n = bei(a, b);
cout << m <<" "<< n;
return 0;
}