Cod sursa(job #739349)

Utilizator speederPetru Radu speeder Data 22 aprilie 2012 19:43:25
Problema Algoritmul lui Euclid Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.37 kb
#include <fstream>
using namespace std;
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int euclid(int x,int y)
{
    int r;
    while(y)
    {
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}
int main()
{
    int n,x,y;
    f>>n;
    for(int i=1;i<=n;i++)
    {
        f>>x>>y;
        g<<euclid(x,y)<<endl;
    }
    return 0;
}