Cod sursa(job #2480246)
| Utilizator | Data | 25 octombrie 2019 09:17:25 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 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 cin("euclid2.in");
ofstream cout("euclid2.out");
int t;
cin >> t;
while(t--)
{
int x,y;
cin >> x >> y;
cout << cmmdc(x,y) << "\n";
}
return 0;
}
