Cod sursa(job #1721441)
Utilizator | Data | 25 iunie 2016 17:45:14 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream f ("euclid2.in");
ofstream g ("euclid2.out");
int T, i;
long long a, b, r, aux;
int main()
{f>>T;
for(i=1; i<=T; i++)
{f>>a>>b;
if(a<b){x=a;y=b;}
else
{x=b;y=a;}
r=y%x;
while(r!=0)
{y=x;x=r;r=y%x;}
g<<x<<endl;
}
return 0;
}