Cod sursa(job #1471786)
Utilizator | Data | 15 august 2015 10:19:49 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include<fstream>
using namespace std;
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int n,a,b;
int cmmdc(int a,int b)
{
int r=0;
while(b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
f>>n;
while(n)
{
n--;
f>>a>>b;
g<<cmmdc(a,b)<<"\n";
}
return 0;
}