Cod sursa(job #2794517)
Utilizator | Data | 5 noiembrie 2021 00:11:13 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int euclid (int x , int y)
{
while(x!=y)
{
if(x < y)
y = y - x ;
else
x = x - y ;
}
return x;
}
int main()
{
int n ;
f >> n ;
for(int i = 1 ; i <= n ; i++ )
{
int x , y ;
f >> x ;
f >> y ;
g << euclid(x,y) << endl ;
}
}