Cod sursa(job #1756744)

Utilizator GyorgyGyorgy Makkay Gyorgy Data 13 septembrie 2016 16:10:14
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb

#include <stdio.h>

int main() {
    int t, a, b, r;
    freopen("euclid2.in", "r", stdin);
    freopen("euclid2.out", "w", stdout);
    scanf("%d", &t);
    while (t--) {
        scanf("%d %d", &a, &b);
        while (b) {
            r = a % b;
            a = b;
            b = r;
        }
        printf("%d\n", a);
    }
    return 0;
}