Cod sursa(job #1644973)

Utilizator serbanSlincu Serban serban Data 10 martie 2016 10:29:17
Problema Algoritmul lui Euclid Scor 60
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) {
            while(x >= y) x -= y;
            z = x; x = y; y = z;
        }
        g << x << "\n";
    }
    return 0;
}