Cod sursa(job #1644970)
Utilizator | Data | 10 martie 2016 10:28:46 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int n, x, y, z; f >> n;
for(; n; n --) {
f >> x >> y;
while(y) {
z = x - (int)(x / y) * y;
x = y; y = z;
}
g << x << "\n";
}
return 0;
}