Cod sursa(job #2278748)
Utilizator | Data | 8 noiembrie 2018 15:18:56 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <stdio.h>
int T, A, B;
int gcd(int a, int b)
{
if (!b) return a;
return gcd(b, a % b);
}
int main(void)
{
freopen("euclid2.in", "r", stdin);
freopen("euclid2.out", "w", stdout);
scanf("%d", &T);
for (; T; --T)
{
scanf("%d %d", &A, &B);
printf("%d\n", gcd(A, B));
}
return 0;
}