辗转相除法求最大公约数
来源:百度文库 编辑:神马文学网 时间:2024/04/28 22:58:58
#include
using namespace std;
void commondevisor(int,int,int &);
void main()
{
int m,n,r,p;
cin>>m>>n;
p=m*n;
commondevisor(m,n,r);
p=p/r; //最小公倍数
cout<}
void commondevisor(int m,int n,int &r)
{
while(m%n!=0)
{
r=m%n;
m=n;
n=r;
}
}
using namespace std;
void commondevisor(int,int,int &);
void main()
{
int m,n,r,p;
cin>>m>>n;
p=m*n;
commondevisor(m,n,r);
p=p/r; //最小公倍数
cout<
void commondevisor(int m,int n,int &r)
{
while(m%n!=0)
{
r=m%n;
m=n;
n=r;
}
}