第一次记录下,辗转相除法。据说是求最大公约数的最简单算法。记录下
#include<stdio.h>
int main()
{
int m,n,r;
scanf("%d%d",&m,&n);
while(r=m%n,r!=0){
m=n;//将较小值保存给较大值
n=r;//将余数保存给较小值
}//利用辗转相除法处理m,n.得到最大公约数
printf("%d\n",n);
return 0;
}

第一次记录下,辗转相除法。据说是求最大公约数的最简单算法。记录下
#include<stdio.h>
int main()
{
int m,n,r;
scanf("%d%d",&m,&n);
while(r=m%n,r!=0){
m=n;//将较小值保存给较大值
n=r;//将余数保存给较小值
}//利用辗转相除法处理m,n.得到最大公约数
printf("%d\n",n);
return 0;
}
文章有(2)条网友点评
At the beginning, I was still puzzled. Since I read your article, I have been very impressed. It has provided a lot of innovative ideas for my thesis related to gate.io. Thank u. But I still have some doubts, can you help me? Thanks.
After reading your article, it reminded me of some things about gate io that I studied before. The content is similar to yours, but your thinking is very special, which gave me a different idea. Thank you. But I still have some questions I want to ask you, I will always pay attention. Thanks.