Cod sursa(job #1049607)
Utilizator | Data | 7 decembrie 2013 16:09:28 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
long x,y,aux;
fin>>x;
while(fin>>x>>y)
{
if(y<x)
{
aux=x;
x=y;
y=aux;
}
if(x==0)
fout<<y;
else
{
while(x!=y)
{
if(y>x)
y=y-x;
else x=x-y;
}
fout<<y;
}
fout<<"\n";
}
return 0;
}