Cod sursa(job #2432665)
Utilizator | Data | 24 iunie 2019 17:39:51 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int main() {
int tests;
fin >> tests;
while (tests) {
int a, b;
fin >> a >> b;
while (a != 0 && b != 0)
{
if (a > b) a = a % b;
else b = b % a;
}
if (a != 0) fout << a << '\n';
else fout << b << '\n';
tests--;
}
return 0;
}