/*输入两个正整数m和n 求其最大公约数和最小公倍数*/
#include<stdio.h>
int main()
{
int m, n, r, temp, p;
printf("输入两个正整数:");
scanf_s("%d%d", &m, &n);
if (m < n)
{
temp = m;
m = n;
n = temp;
}
p = m * n;
while (n != 0)
{
r = m % n;
m = n;
n = r;
}
printf("最大公约数为:%d", m);
printf("最小公倍数为:%d", p / m);
}
运行结果