#include
#include
void swap(int *num1, int *num2){
int temp;
if (*num1 > *num2){
temp = *num1;
*num1 = *num2;
*num2 = temp;
}
}
int GCD(int num1, int num2){ // 最大公约数
if (num1 == 1) return 1;
for (int i = num1; i >= 1; i--){
if (num1%i == 0 && num2%i == 0) return i;
}
return 1;
}
int LCM(int num1, int num2){ // 最小公倍数
int mult = 1, product = 0;
while (true)
{
product = mult*num2;
if (product%num1 == 0 && product%num2 == 0) return product;
++mult;
}
}
int main(){
int num1, num2;
scanf("%d %d", &num1, &num2);
swap(&num1, &num2);
printf("%d %d\n", GCD(num1, num2), LCM(num1, num2));
system("pause");
return 0;
}
#include
int maxCommonDivisor(int x,int y)
{
if(x
while(y)
{
int temp=x;
x=y;
y=temp%y;
}
return x;
}
int minCommenMultiple(int x,int y)
{
int temp=maxCommonDivisor(x,y);
return x/temp*y;
}
int main()
{
int first,second;
scanf(“%d%d",&first,&second);
int MAX=maxCommonDivisor,MIN=minCommenMultiple;
printf("最大公约数为%d,最小公倍数为%d",&MAX,&MIN);
}