最大公约数算法

类别:软件工程 点击:0 评论:0 推荐:

#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;

}

本文地址:http://com.8s8s.com/it/it35941.htm