#include<iostream>
using namespace std;
int max(int,int);
int small(int,int);
int main()
{
int a,b,c,d;
cin>> a>> b;
c= max(a,b);
d= small(a,b);
cout<< "max="<< c<< endl;
cout<< "small=" << d<< endl;
system("pause");
return 0;
}
int max(int x,int y)
{
int z;
for(z=x<y?x:y ; z>=1 ; z--) 求x,y中小的那个给z,如
if(x%z==0 && y%z==0) 果能整除,返回Z值。如
return z; 不能把Z减1后再比较。
}
int small(int x,int y)
{
int z;
z=max(x,y);
return (x*y/z);
}
函数调用看起来可能比较直观一点。