Cod sursa(job #2979062)

Utilizator FishyYoruCojocinescu Andreea Ayana FishyYoru Data 14 februarie 2023 19:09:22
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 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 cmmdc(int a, int b) 
   {
        while(b!=0) 
        {
        int d=a%b;
        a=b;
        b=d;
        }
    return a;
   }
int n, a, b; 
int main()
{
    fin>>n;
    for(int i=1;i<=n;i++)
    {
     fin>>a>>b;
    fout<<cmmdc(a,b)<<"\n";
    }
    fin.close();
    fout.close();
    return 0;
}