Cod sursa(job #2511531)
Utilizator | Data | 19 decembrie 2019 11:13:50 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream fin ("euclid2.in");
ofstream fout ("euclid2.out");
int cmmdc ( int x, int y );
int main()
{
int t, a, b;
fin >> t;
while ( t-- )
{
fin >> a >> b;
fout << cmmdc ( a, b ) << '\n';
}
return 0;
}
int cmmdc ( int x, int y )
{
int r = x % y;
while ( r )
{
x = y;
y = r;
r = x % y;
}
return y;
}