Cod sursa(job #2760048)
Utilizator | Data | 22 iunie 2021 18:14:22 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
int lnko(int a, int b)
{
if(b==0) return a;
else lnko(b, a%b);
}
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int x,y;
f>>x;
while(f>>x){
f>>y;
if(x>y) g<<lnko(x,y)<<endl;
else g<<lnko(y,x)<<endl;
}
f.close();
g.close();
return 0;
}