Cod sursa(job #1741971)
Utilizator | Data | 15 august 2016 15:59:47 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream fin ("euclid2.in");
ofstream fout ("euclid2.out");
int euclid(int x, int y){
int r;
while(y){
r = x % y;
x = y;
y = r;
}
return x;
}
int main(){
int t, x, y;
fin >> t;
while (t--){
fin >> x >> y;
fout << euclid(x, y) << "\n";
}
return 0;
}