Cod sursa(job #2336363)

Utilizator benjamin2205Zeic Beniamin benjamin2205 Data 5 februarie 2019 05:44:36
Problema Algoritmul lui Euclid Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int n;

void citire();

int euclid(int a, int b) {
    int r;

    while(r != 0) {
        r = a%b;
        a = b;
        b = r;
    }
    g << a << '\n';
}

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

void citire() {
    int a, b;

    f >> n;
    for(int i = 1; i <= n; ++i) {
        f >> a >> b;
        if (a > b)
            euclid(a,b);
        else
            euclid(b,a);
    }
}