1 #include <stdio.h>
 2 int main()
 3  {
 4   int  p,r,n,m,temp;
 5   printf("请输入两个正整数n,m:");
 6   scanf("%d,%d,",&n,&m);
 7   if (n<m)
 8    {
 9     temp=n;
10     n=m;
11     m=temp;
12    }
13   p=n*m;
14   while(m!=0)//辗转相处法
15    {
16     r=n%m;
17     n=m;
18     m=r;
19    }
20   printf("它们的最大公约数为:%d\n",n);
21   printf("它们的最小公倍数为:%d\n",p/n);//最小公倍数=两数之积/最大公约数!
22   return 0;
23  }

 

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
相关资源
相似解决方案