Cod sursa(job #2795603)

Utilizator P1zd0SuntBetoAlbert Beto P1zd0SuntBeto Data 6 noiembrie 2021 17:50:09
Problema Algoritmul lui Euclid Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <iostream>
#include <fstream>
using namespace std;

int cmmdc(int n,int m)
{
    int x;
    while (m)
    {
        x = n % m;
        n = m;
        m = x;
    }
    return n;
}
int main()
{
    ifstream f("euclid2.in");
    ofstream o("euclid2.out");
    int n;
    f >> n;
    int a, b;
    while (n)
    {
        f >> a >> b;
        o << cmmdc(a,b) << endl;
    }
    return 0;
}