Cod sursa(job #1108090)

Utilizator AllexX7Alexandru Mares AllexX7 Data 15 februarie 2014 13:16:22
Problema Algoritmul lui Euclid Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream in("euclid2.in");
    ofstream out("euclid2.out");
    int n,a,b,i;
    in>>n;
    for (i=0;i<n;i++)
    {
        in>>a>>b;
        while(a!=b)
            if(a>b)
                a=a-b;
            else b=b-a;
        out<<b<<'\n';
    }
}