Cod sursa(job #756073)
Utilizator | Data | 8 iunie 2012 22:48:36 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
int main () {
int t, a, b, c;
freopen ("euclid2.in", "rt", stdin);
freopen ("euclid2.out", "wt", stdout);
for (scanf ("%d", &t); t; -- t) {
scanf ("%d%d", &a, &b);
while (a) {
c = b % a;
b = a;
a = c;
}
printf ("%d\n", b);
}
return 0;
}