Cod sursa(job #2824549)

Utilizator csoareCristian Soare csoare Data 2 ianuarie 2022 16:48:17
Problema Algoritmul lui Euclid Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.33 kb
#include <fstream>
#include <iostream>

int main() {
	std::ifstream fin("euclid2.in");
	std::ofstream fout("euclid2.out");

	int n;
	fin >> n;

	while (n--) {
		int a, b;
		fin >> a >> b;
		std::cout << a << " " << b << std::endl;

		int t;
		while (b) {
			t = b;
			b = a % b;
			a = t;
		}

		fout << a << std::endl;
	}
	return 0;
}