Cod sursa(job #2285370)
Utilizator | Data | 18 noiembrie 2018 15:10:56 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fi("euclid2.in");
ofstream fo("euclid2.out");
int nrTeste;
int euclid(int a,int b)
{
int c;
while(b)
{
c=a%b;
a=b;
b=c;
}
return a;
}
int main()
{
fi>>nrTeste;
for(int test=1; test<=nrTeste; test++)
{
int a,b;
fi>>a>>b;
fo<<euclid(a,b)<<endl;
}
return 0;
}