#include "stdio.h"
unsigned int Gcd(unsigned int M, unsigned int N)
{
unsigned int Rem;
while(N > 0)
{
Rem = M % N;
M = N;
N = Rem;
}
return M;
}
//测试
int main()
{
printf("Gcd for 12 and 34 :%d/n", Gcd(12, 34));
return 0;
}
博客展示了一个计算最大公约数的算法实现。通过C语言代码,定义了Gcd函数,利用循环计算两个无符号整数的最大公约数。最后在main函数中对该函数进行测试,输出12和34的最大公约数。
#include "stdio.h"
unsigned int Gcd(unsigned int M, unsigned int N)
{
unsigned int Rem;
while(N > 0)
{
Rem = M % N;
M = N;
N = Rem;
}
return M;
}
//测试
int main()
{
printf("Gcd for 12 and 34 :%d/n", Gcd(12, 34));
return 0;
}

被折叠的 条评论
为什么被折叠?