Cod sursa(job #1937913)

Utilizator savigunFeleaga Dragos-George savigun Data 24 martie 2017 13:30:58
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <iostream>
#include <fstream>

using namespace std;


ifstream in("euclid2.in");
ofstream out("euclid2.out");

int cmmdc(int a, int b){
    int t;
    while (b != 0) {
        t = b;
        b = a % b;
        a = t;
    }

    return a;
}

int main()
{

    int t, a, b, r;

    in >> t;;

    for (int i = 1; i <= t; ++i) {
        in >> a >> b;
        out << cmmdc(a, b) << "\n";
    }


    return 0;
}