Cod sursa(job #2559858)

Utilizator NotTheBatmanBruce Wayne NotTheBatman Data 27 februarie 2020 17:50:46
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include <fstream>

using namespace std;

int Euclid (int a, int b)
{
    int r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

void Read ()
{
    ifstream fin ("euclid2.in");
    ofstream fout ("euclid2.out");
    int n, x, y;
    fin >> n;
    while (n--)
    {
        fin >> x >> y;
        fout << Euclid(x, y) << "\n";
    }
    fout.close();
}

int main()
{
    Read();
    return 0;
}