locale-test/04.cpp

25 lines
295 B
C++

#include<iostream.h>
int main()
{
int m,n,a,b,p,q;
cout<<"请输入两个正整数m,n:\n";
cin>>m>>n;
a=m;
b=n;
while(a%b!=0)
{
p=a%b;
a=b;
b=p;
}
for(q=1;q<=m*n;q++)
if((q%m==0)&&(q%n==0))
break;
cout<<"最大公约数:"<<b<<endl;
cout<<"最小公倍数:"<<q<<endl;
return 0;
}