Cod sursa(job #2949044)

Utilizator slol003Rizea Alexandru-Gabriel slol003 Data 29 noiembrie 2022 15:35:37
Problema Algoritmul lui Euclid Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.7 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");

int T;
int a,b,tmp;
int main()
{
    fin >>T;
    while (T!=0)
    {
        fin>>a>>b;
        while (b>0)
        {
            tmp=b;
            b=b%a;
            a=tmp;
        }
        fout <<a <<"\n";
        T--;
    }
    
    return 0;
}