Cod sursa(job #2212536)

Utilizator pacheprotopopescuPake Protopopescu pacheprotopopescu Data 14 iunie 2018 13:05:02
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int n,x,y;
int cmmdc(int a,int b)
{
    while(b!=0)
    {
        int r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int main()
{
   f>>n;
   for(int i=1;i<=n;i++)
   {
       f>>x>>y;
       g<<cmmdc(x,y)<<"\n";
   }
}