Cod sursa(job #2041372)
Utilizator | Data | 17 octombrie 2017 10:20:41 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int cmmdc (int x, int y) {
int r;
while (y) {
r = x % y;
x = y;
y = r;
}
return x;
}
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int i, t, a, b; f>>t;
for (i=1; i<=t; i++) {
f>>a>>b;
g<<cmmdc(a,b)<<endl;
}
}