Cod sursa(job #154390)

Utilizator mithyPopovici Adrian mithy Data 11 martie 2008 10:09:29
Problema Algoritmul lui Euclid Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include <stdio.h>

long long a, b, n;


void cmmdc()
{
   long long r;

   while (b)
   {
      r = a % b;
      a = b;
      b = r;
   }

   printf( "%lld\n", a );
}

int main()
{
   long long i;

   freopen( "euclid.in", "rt", stdin );
   freopen( "euclid.out", "wt", stdout );

   scanf( "%lld", &n );

   for (i=0; i<n; i++)
   {
      scanf( "%lld %lld", &a, &b );
      cmmdc();
   }

   return 0;
}