最小公倍数和最大公约数
#include<iostream>
using namespace std;
int fun(int m,int n,int &gcd)
{
int a=m,b=n,t;
if(a<b)
{
t=a;
a=b;
b=t;
}
gcd=b;
while(a%b!=0)
{
gcd=a%b;
a=b;
b=gcd;
}
{
int x;
x=(m*n)/gcd;
return x;
}
}
int main()
{
int m,n,k;
cout<<"请输入两个整数:";
cin>>m>>n;
cout<<"这两个数的最小公倍数是:"<<fun(m,n,k)<<endl;
cout<<"这两个数的最大公约数是:"<<k<<endl;
}