Cod sursa(job #2636763)

Utilizator AndreiPavuhlAndrei Paval AndreiPavuhl Data 19 iulie 2020 18:40:59
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("euclid2.in");
ofstream fout("euclid2.out");

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

int main()
{
    int t, a, b;
    fin >> t;
    while (t--)
    {
        fin >> a >> b;
        fout << cmmdc(a, b) << '\n';
    }

    return 0;
}