Cod sursa(job #2088733)

Utilizator kodama cheama alex koda Data 15 decembrie 2017 19:30:10
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.31 kb
#include <fstream>

using namespace std;

int main () {
  ifstream fin ("euclid2.in");
  ofstream fout ("euclid2.out");
  int a, b, r, n, i;
  fin>>n;
  for ( i = 0; i < n; i++ ) {
    fin>>a>>b;
    while ( b ) {
      r = a % b;
      a = b;
      b = r;
    }
    fout<<a<<"\n";
  }
  return 0;
}