Cod sursa(job #2205866)
Utilizator | Data | 20 mai 2018 15:24:01 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int x, y,n, min, maxc,max;
fin >> n;
for (int j = 1; j <= n; j++) {
fin >> x >> y;
if (y > x) {
max = y;
min= x;
}
else {
max = x;
min = y;
}
//cout << max;
y = min;
while (y != 0) {
x = min;
y = max % min;
max = x;
min = y;
}
fout << "" << x << endl;
}
return 0;
}