在尝试从简化的编程中执行 GCD 和 LCM 程序时……我遇到了结果问题。我做的一切都是正确的(根据我),甚至逐字检查,但问题仍然存在......我只粘贴正常方法的代码。
#include <stdio.h>
int main()
{
int a, b, x, y, t, gcd, lcm;
printf("Enter first number :");
scanf("%d", &a);
printf("Enter first number :");
scanf("%d", &b);
a = x;
b = y;
while (b != 0)
{
t = b;
b = a % b;
a = t;
}
gcd = a;
lcm = (x * y)/gcd;
printf("Greatest common divisior of %d and %d = %d\n", x, y, gcd);
printf("Lowest common divisior of %d and %d = %d\n", x, y, lcm);
getch();
}