课后作业
#include <stdio.h>
int main() {
int a, b, c, d,e,f;
scanf("%d %d", &a, &b);
if (a < b) {
c = a;
a = b;
b = c;
}
d=a;
e=b;
while (b != 0) {
c = a % b;
a = b;
b = c;
}//欧几里得算法
f=(d*e)/a;
printf("最大公约数是:%d\n最小公倍数是:%d", a,f);
return 0;
}
1 条评论
好