#include<iostream>
using namespace std;
int count = 0;
//ÆäÖÐ a>b
int gcd( int a, int b ){
count ++;
if( b == 0 )
return a;
return gcd(b,a%b);
}
int main()
{
int a = 27;
int b = 81;
//cout << gcd(a,b) << endl;
int g = gcd(a,b);
cout << g << endl;
//Á½¸öÊýͬʱ³ý×î´ó¹«Ô¼Êý ¼´Ô¼·Ö³É×î¼òÐÎʽ
a /= g;
b /= g;
cout << a << " " << b << endl;
//ÔËÐдÎÊý
cout << "count = " << count << endl;
return 0;
}
GCD
最新推荐文章于 2024-08-07 12:03:27 发布