Cod sursa(job #3184570)

Utilizator denizza07Birau Denisa denizza07 Data 16 decembrie 2023 11:18:10
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <fstream>

using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int euclid(int a, int b){
    while(b!= 0)
    {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int main()
{
    int n,a,b;
    fin>>n;
    for(int i=1;i<=n;i++){
        fin>>a>>b;
        fout<<euclid(a,b)<<endl;
    }
    

    return 0;
}