Cod sursa(job #2193615)

Utilizator secenAxinte Gabriel secen Data 10 aprilie 2018 18:44:18
Problema Algoritmul lui Euclid Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
// Infoarena.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <fstream>

using namespace std;

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

unsigned long euclid(unsigned long a, unsigned long b)
{
	if (!b)
		return a;
	euclid(b, a%b);
}

int main()
{
	unsigned long x, y, n;
	fin >> n;
	for (unsigned long i = 0; i < n; i++)
	{
		fin >> x >> y;
		fout << euclid(x, y)<<"\n";
	}
    return 0;
}