Cod sursa(job #154955)

Utilizator thestickTudor A thestick Data 11 martie 2008 16:55:32
Problema Algoritmul lui Euclid Scor 100
Compilator c Status done
Runda Arhiva educationala Marime 0.32 kb
#include <stdio.h>

long euclid(long a,long b)
{
if(b==0) return a;
return euclid(b, a%b);
}

int main()
{
long a,b,t;
FILE *f,*g;

f=fopen("euclid2.in","r");
g=fopen("euclid2.out","w");

fscanf(f,"%ld",&t);

while(t)
	{
	t--;
	fscanf(f,"%ld %ld",&a,&b);
	fprintf(g,"%ld\n",euclid(a,b));
	}

fclose(f);
fclose(g);

return 0;
}