Cod sursa(job #2278740)
Utilizator | Data | 8 noiembrie 2018 15:12:12 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include<fstream>
using namespace std;
int euclid(int a, int b)
{
int r=1;
while(r)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
ifstream cin("euclid2.in");
ofstream cout("euclid2.out");
int a,b,t,i;
cin>>t;
for(i=1;i<=t;++i)
{
cin>>a>>b;
cout<<euclid(a,b)<<endl;
}
}