#include <stdio.h>
/* 最大公约数 */
int gcd(int a, int b) {
int t;
if (a < b)
t = a, a = b, b = t;
while (b != 0)
t = a % b, a = b, b = t;
return a;
}
/* 最小公倍数 */
int lcm(int a, int b, int c) {
return a * b / c;
}
void main() {
int x, y, a, b;
scanf("%d%d", &x, &y);
a = gcd(x, y);
b = lcm(x, y, a);
printf("gcd=%d,lcm=%d", a, b);
}
求数字:求两个整数的最大公约数及最小公倍数。
猜你喜欢
转载自blog.csdn.net/qq_38490457/article/details/104576979
今日推荐
周排行