Cod sursa(job #2723381)

Utilizator BalogOctavianBalog Octavian Gheorghe BalogOctavian Data 13 martie 2021 23:07:17
Problema Algoritmul lui Euclid Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.4 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("euclid2.in");
ofstream g("euclid2.out");

cmmdc(int a, int b)
{
    if (a%b == 0) return b;
    return cmmdc (b,a%b);
}

void test()
{
    int a,b;
    f >> a >> b;
    g << cmmdc(a,b) << '\n';
}

int main()
{
    int t;
    f >> t;
    while(t)
    {
        test();
        t--;
    }
    return 0;
}