#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;
}
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。