Cod sursa(job #3153271)

Utilizator trifangrobertRobert Trifan trifangrobert Data 28 septembrie 2023 23:37:21
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.36 kb
#include <fstream>

using namespace std;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    ifstream fin("euclid2.in");
    ofstream fout("euclid2.out");
    int tests;
    fin >> tests;
    while (tests-- > 0) {
        int a, b;
        fin >> a >> b;
        fout << gcd(a, b) << "\n";
    }
    fin.close();
    fout.close();
    return 0;
}