项目2:最大公约数和最小公倍数
#include<iostream>
using namespace std;
int leasemul;
int f1(int m,int n)
{
int temp;
if(m<n)
{
f1(n,m);
}
else
{
while(n!=0)
{
temp=m%n;
m=n;
n=temp;
}
leasemul=m;
}
return 0;
}
int f2(int m,int n)
{
int temp;
temp=(m*n)/leasemul;
return temp;
}
int main(int argc,char * argv[])
{
int m,n;
cout<<"请输入俩个数据:";
cin>>m>>n;
f1(m,n);
cout<<m<<"与"<<n<<"最大公约数是:";
cout<<leasemul<<endl;
cout<<m<<"与"<<n<<"最大公倍数是:";
cout<<f2(m,n)<<endl;
return 0;
}