Cod sursa(job #2129993)

Utilizator GandalfTheWhiteGandalf the White GandalfTheWhite Data 13 februarie 2018 12:49:29
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include <cstdio>
using namespace std;

inline int cmmdc(int x,int y)
{
    int r=x%y;

    while (r)
    {
        x=y;
        y=r;
        r=x%y;
    }

    return y;
}

int n,x,y;
int main()
{
    freopen("euclid2.in","r",stdin);
    freopen("euclid2.out","w",stdout);

    scanf("%d",&n);

    while (n--)
    {
        scanf("%d%d",&x,&y);

        printf("%d\n",cmmdc(x,y));
    }
    return 0;
}