Cod sursa(job #275098)
Utilizator | Data | 10 martie 2009 10:53:44 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
long x;
f>>x;
long a,b,r;
while(x!=0)
{
f>>a>>b;
while(b!=0){r=a%b;a=b;b=r;}
g<<a<<'\n';
x--;
}
g.close();
return 0;
}