Cod sursa(job #587594)

Utilizator buclucashuMihai Moldovan buclucashu Data 5 mai 2011 11:49:14
Problema Algoritmul lui Euclid Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include<fstream>
using namespace std;
int divizor(int a, int b)
{
	int r;
	do{
		r=a%b;
		a=b;
		b=r;
	}while(r);
	return a;
}
int main()
{
	ifstream f("euclid2.in");
	ofstream g("euclid2.out");
	int t,a,b;
	f>>t;
	while(t)
	{
		f>>a;
		f>>b;
		g<<divizor(a,b)<<endl;
		t--;
	}
	f.close();
	g.close();
	return 0;
}