Cod sursa(job #2334441)
Utilizator | Data | 2 februarie 2019 17:04:38 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int x, y, T;
int main(){
fin >> T;
for(int i=0; i<T; i++){
fin >> x >> y;
if(y>x)
swap(x,y);
while(y!=0){
int r=x%y;
x=y;
y=r;
}
fout << x << "\n";
}
}