Cod sursa(job #2194570)
| Utilizator | Data | 13 aprilie 2018 19:19:04 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
// euclidalg.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int t;
pair <int, int> cmd;
inline int gcd(int a, int b)
{
if (!b) return a;
return gcd(b, a % b);
}
int main()
{
cin >> t;
for (int i = 1; i <= t; i++)
{
cin >> cmd.first >> cmd.second;
cout << gcd(cmd.first, cmd.second);
}
return 0;
}
