Cod sursa(job #1501618)

Utilizator KanghuAndre Popescu Kanghu Data 13 octombrie 2015 18:00:17
Problema Algoritmul lui Euclid Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include <iostream>
#include <fstream>

using namespace std;

int foo(int a, int b)
{
    if(b == 0) return a;

    foo(b, a % b);
}

int main()
{
    ifstream i("euclid.in");
    ofstream o("euclid.out");

    int x;

    i >> x;

    for(int a = 0; a < x; a++)
    {
        int k, j;

        i >> k >> j;

        o << foo(k, j) << '\n';
    }

    return 0;
}