Cod sursa(job #2648532)

Utilizator bubblegumixUdrea Robert bubblegumix Data 11 septembrie 2020 13:04:53
Problema Algoritmul lui Euclid Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include<fstream>
using namespace std;
long n,x,y;
long cmmdc(long x,long y)
{
  while(y)
  {
      int r=x%y;
      x=y;
      y=r;
  }
  return x;

}
int main()
{
    ifstream f("euclid2.in");
    ofstream g("euclid2.out");
    f>>n;
    for(int i=1;i<=n;i++)
    {
        f>>x>>y;
        if(x>y)
             g<<cmmdc(x,y)<<endl;
           else
             g<<cmmdc(y,x)<<endl;


    }
    f.close();
    g.close();
    return 0;
}