Cod sursa(job #2293813)

Utilizator PopescuAndreiAlexandruPopescu Andrei Alexandru PopescuAndreiAlexandru Data 1 decembrie 2018 16:51:24
Problema Algoritmul lui Euclid Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.37 kb
#include <iostream>
#include <fstream>

using namespace std;

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


unsigned euclid(unsigned a, unsigned b)
{
    if(b==0)
        return a;
    return euclid(b,a%b);
}
int n,i,a,b;

int main()
{
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>a>>b;
        fout<<euclid(a,b)<<endl;
    }
}