//
实验一
.cpp :
求最大公约数的三种算法
//
#include "stdafx.h"
#include "time.h"
#include
using namespace std;
int gcd1(int m, int n){
int t = m>n ? m : n;
while (t>0){
if (m%t == 0){
if (n%t == 0){
return t;
}
}
t--;
}
}
int gcd2(int m, int n){
int r = m%n;
while (r != 0){
m = n;
n = r;
r = m%n;
}
return n;
}
int decompose(int num, int p[])
{
int i=2, count=0;
while(i<=num){
while(num%i ==0){
p[count++]=i;
num/=i;
}
i++;
}
return count;
}
int gcd3(int m, int n)
{
int a[100], b[100], c[100];
int la=decompose(m, a);
int lb=decompose(n, b);
int i=0, j=0, k=0;