Cod sursa(job #499528)
Utilizator | Data | 10 noiembrie 2010 09:33:49 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main()
{int T,i=0,a,b;
ifstream f("euclid2.in");
ofstream g("euclid2.out");
f>>T;
while(i<T){
f>>a>>b;
while(a!=b){
if(a>b)
a=a-b;
else b=b-a;
}
g<<b<<endl;
i++;
}
g.close();
}