Cod sursa(job #2551281)
Utilizator | Data | 19 februarie 2020 18:33:32 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp-32 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int div(int a, int b)
{
if (a==b)
return b;
if (a>b)
a = a-b;
else
b = b-a;
return div(a, b);
}
int main()
{
int t, a, b; in >> t;
while (t>0)
{
in >> a >> b;
out << div(a, b) << "\n";
t--;
}
}