Cod sursa(job #965651)
| Utilizator | Data | 24 iunie 2013 13:12:44 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <fstream>
using namespace std;
void work(ifstream &fin, ofstream &fout){
int perechiDeNumere;
int a, b;
fin>>perechiDeNumere;
for(int i = 1; i <= perechiDeNumere; i++){
fin>>a>>b;
int r;
while(b){
r = a%b;
a = b;
b = r;
}
fout<<a<<endl;
}
}
int main()
{
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
work(fin, fout);
fin.close();
fout.close();
return 0;
}
