输入两个数,求这两个数的最大公约数。
#include<iostream>
using namespace std;
int zbgy(int a, int b)
{
if (a%b == 0)
return b;
else
{
return (zbgy(b, a%b));
}
}
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a%b);
}
int main()
{
int a, b;
cin >> a >> b;
int m,n;
m = a;
n = b;
cout << zbgy(a, b);
cout << endl << gcd(a, b)<<endl;
cout<<m*n/zbgy(a, b)<<endl;
return 0;
}