Cod sursa(job #1946544)
Utilizator | Data | 30 martie 2017 10:30:44 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int a, int b)
{
int r;
while(b){
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int t, a, b, i;
f>>t;
for(i=1;i<=t;i++){
f>>a>>b;
g<<cmmdc(a,b)<<'\n';
}
return 0;
}