Cod sursa(job #2762340)
Utilizator | Data | 6 iulie 2021 16:22:10 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
/*int lnko(int a, int b)
{
if(!b) return a;
else lnko(b, a%b);
}*/
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int n,x,y,a,b,aux;
f>>n;
for(; n>0; n--){
f>>x>>y;
if(x<y){
aux=x;
x=y;
y=aux;
}
while(y!=0){
aux=x;
x=y;
y=aux%y;
}
g<<x<<endl;
}
return 0;
}