解题思路:用递归和更相相减术解决问题
注意事项:
参考代码:
#include<stdio.h>
#include<math.h>
static int gxxjs(int a, int b);
int the_1011th(void)
{
int a, b, max, min;
scanf("%d %d", &a, &b);
if (a <= 0 || b <= 0)
return -1;
if (a == b)
max = a;
max = gxxjs(a, b);
min = a * b / max;
printf("%d %d\n", max, min);
return 0;
}
/*更相相减术*/
static int gxxjs(int a, int b)
{
int temp = a - b;
if (temp == a || temp == b)
{
return temp;
}
if (temp > 0)
{
a = b;
b = temp;
}
if (temp < 0)
b = -temp;
return gxxjs(a, b);
}
0.0分
0 人评分