Cod sursa(job #2755875)
Utilizator | Data | 28 mai 2021 17:12:29 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
int eucl(int x, int y){
int r;
while(y){
r = x%y;
x = y;
y = r;
}
return x;
}
int main()
{
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int T, x, y;
fin >> T;
for(;T;T--){
fin >> x >> y;
fout << eucl(x, y) << '\n';
}
}