Cod sursa(job #616373)

Utilizator juliussSimion Stefan juliuss Data 12 octombrie 2011 13:54:11
Problema Algoritmul lui Euclid Scor 0
Compilator c Status done
Runda Arhiva educationala Marime 0.4 kb
#include <stdio.h>

int gcd(int, int);

int
main(void)
{
	int a, b, T;

	freopen("euclid2.in", "r", stdin);
	freopen("euclid2.out", "w", stdout);

	scanf("%d", &T);
	
	while(T)
	{
		scanf("%d%d", &a, &b);
		printf("gcd dintre %d si %d este: %d\n", a, b, gcd(a, b));		
		T--;
	}

	return 0;
}

int 
gcd(int a, int b)
{
	if(b == 0)
		return a;
	else
		return gcd(b, a % b);
}