Cod sursa(job #912020)
| Utilizator | Data | 12 martie 2013 00:07:31 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <cstdio>
using namespace std;
int cmmdc(int x, int y)
{
while(y)
{
int r = x % y;
x = y;
y = r;
}
return x;
}
int main()
{
int t;
int x;
int y;
freopen("euclid2.in", "r", stdin);
freopen("euclid2.out", "w", stdout);
scanf("%d\n", &t);
while(t --)
{
scanf("%d %d\n", &x, &y);
printf("%d\n", cmmdc(x, y));
}
return 0;
}
