Cod sursa(job #1777462)
Utilizator | Data | 12 octombrie 2016 15:22:12 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
const string fis = "euclid2";
ifstream is(fis + ".in");
ofstream os(fis + ".out");
int main()
{
int t, a, b, rest;
is >> t;
while ( t-- )
{
is >> a >> b;
while ( b )
{
rest = a % b;
a = b;
b = rest;
}
os << a << "\n";
}
is.close();
os.close();
return 0;
}