#include <iostream>
using namespace std;
zdgys(int x,int y) /*最大公约数函数*/
{ int r, t;
if(x<y){t=x;x=y;y=t;}
r=x%y;
while(r!=0) /* r为x/y余数*/
{ r=x%y;
if (r==0)
return y;
x=y;
y=r; }}
zxgbs(int x,int y) /*最小公倍数函数*/
{
return((x*y)/zdgys(x,y));/*在返回值表达式中调用zdgys()函数*/
}
main()
{
int a,b;
cout<<"input two numbers:\n";
cin>>a>>b;
cout<<"maxgys="<<zdgys(a,b)<<",\tmingbs="<<zxgbs(a,b);/*调用函数*/
}
输出结果: