Cod sursa(job #2059720)
Utilizator | Data | 7 noiembrie 2017 15:40:43 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
using namespace std;
long gcd(long a , long b)
{
while (a!=b)
{
if (a>b){
a=a-b;
}
{
if (b>a) { b=b-a; }
}
}
return a;
}
int main()
{
ifstream f("euclid2.in");ofstream g("euclid2.out");
int n;
f>>n;
for ( int i=1; i<= T; i++)
{
f>>a>>b;
cout << gcd(a,b) << endl;
}
}