Cod sursa(job #2280756)

Utilizator radu_stStoican Radu radu_st Data 11 noiembrie 2018 09:38:37
Problema Algoritmul lui Euclid Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <fstream>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int main() {
int T , a , b , i , z , x , y;
fin >> T;
for(i = 1; i <= T; i++){
    fin >> a >> b;
    x = a;
    y = b;
    while(x != y){
        if(x > y){
            x = x - y;
        }else{
        y = y - x;
        }
    }
    fout << x << "\n";
}
fout.close();
fin.close();
return 0;
}