#include <iostream>
using namespace std;
int gyx(int,int);
int gbx(int,int);
int main()
{
int a,b; cout<<"请输入2个整数";
cin>>a>>b;
cout<<"最大公约数为"<<gyx(a,b)<<endl;
cout<<"最小公倍数为"<<gbx(a,b)<<endl;
system("pause");
return 0;
}
int gyx(int x,int y)
{
int z;
z=(x<y)? x:y;
for(;x%z!=0 || y%z!=0;z--);
return z;
}
int gbx(int x,int y)
{
int c;
c=x*y/gyx(x,y);
return c;
}
原文地址:https://www.cnblogs.com/Eternal-kong/p/8413661.html
时间: 2024-10-10 02:17:32