Cod sursa(job #2372966)
Utilizator | Data | 7 martie 2019 11:38:53 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
int gcd(int a, int b)
{
int r=a%b;
while (r)
{
a=b;
b=r;
r=a%b;
}
return b;
}
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int T, a, b;
f>>T;
while (T--)
{
f>>a>>b;
g<<gcd(a, b)<<'\n';
}
}