Cod sursa(job #2643667)
Utilizator | Data | 20 august 2020 20:04:20 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.61 kb |
#include <bits/stdc++.h>
using namespace std;
int cmmdc(int a,int b)
{
int r;
while(b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
#ifdef HOME
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
#endif // HOME
#ifndef HOME
freopen("euclid2.in","r",stdin);
freopen("euclid2.out","w",stdout);
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,i,a,b;
cin>>n;
for(i=1; i<=n; i++)
{
cin>>a>>b;
cout<<cmmdc(a,b)<<'\n';
}
return 0;
}