Cod sursa(job #2615919)

Utilizator suranimariaMaria Surani suranimaria Data 15 mai 2020 20:27:18
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>

using namespace std;
ifstream fin ("euclid2.in");
ofstream fout ("euclid2.out");

int main()
{
    int t , x , y ;
    fin >> t ;
    for ( int i = 0 ; i < t ; i++ )
        {
            fin >> x >> y ;
            while ( y != 0 )
                {
                    int rest = x % y ;
                    x = y ;
                    y = rest ;
                }
            fout << x << '\n' ;
        }
    return 0;
}