Pagini recente » Cod sursa (job #2804634) | Cod sursa (job #2055471) | Cod sursa (job #508060) | Cod sursa (job #1840512) | Cod sursa (job #2954411)
#include <stdio.h>
#include <math.h>
int main()
{
FILE* f;
FILE* g;
f=fopen("euclid2.in","r");
g=fopen("euclid2.out","w");
long int a, b, T, cmmdc=0, min, max;
fscanf(f,"%ld",&T);
for(int i=1;i<=T;i++)
{
fscanf(f,"%ld%ld",&a,&b);
if (a < b)
{
min=a;
max=b;
}
else
{
max=a;
min=b;
}
for(int q=0;q<=min;q++)
{
cmmdc = max % min;
max = min;
min = cmmdc;
}
fprintf(g,"%ld\n",max);
if(feof(f))
{
break;
}
}
}