Text: |
ԲΠ= GVA
Çàïèòàííÿ:/*
Íàïèñàòè á³íàðíèé àëãîðèòì, ùî âèêîðèñòîâóº ñï³ââ³äíîøåííÿ
ÍÎÄ(a, b)=ÍÎÄ(a mod b, b) ïðè a >= b ÍÎÄ (a, b)=ÍÎÄ (a, b mod a) ïðè b >= a
*/
#include <iostream>
#include <stdio.h>
using namespace std;
int gcd (int a, int b) {
if (b == 0)
return a;
else
return gcd (b, a % b);
}
int main(int argc, char* argv[])
{
int a,b;
cout<<"Enter A : ";
cin>>a;
cout<<"Enter B : ";
cin>>b;
cout<<" GCD = "<<gcd(a,b)<<endl;
system("pause");
return 0;
}
//---------------------------------------------------------------------------
====================================
|