Cod sursa(job #283311)
Utilizator | Data | 18 martie 2009 23:22:57 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
#define NUME "euclid2"
ifstream fi(NUME".in");
ofstream fo(NUME".out");
int cmmdc(int a, int b) {
while (a | b) {
if (a > b) a %= b;
else b %= a;
}
return a | b;
}
int main()
{
int T, x, y;
fi >> T;
while (T--) {
fi >> x >> y;
fo << cmmdc(x, y) << "\n";
}
return 0;
}