Cod sursa(job #477407)
Utilizator | Data | 14 august 2010 14:42:39 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in ("euclid2.in");
ofstream out ("euclid2.out");
int t, x, y;
in >> t;
for (int i = 0; i < t; i++)
{
in >> x >> y;
while (x > 0 && y > 0)
x > y ? x = x % y : y = y % x;
out << (x > 0 ? x : y) << endl;
}
in.close();
out.close();
}