Cod sursa(job #477412)
Utilizator | Radu Coman - UPB radu.coman | Data | 14 august 2010 14:54:15 |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in ("euclid2.in");
ofstream out ("euclid2.out");
int t, x, y, aux;
in >> t;
for (; t; --t)
{
in >> x >> y;
if (x == 0) {out << y << endl; continue; }
while (y > 0)
{
aux = x;
x = y;
y = aux % x;
}
out << x << endl;
}
in.close();
out.close();
return 0;
}