Cod sursa(job #3205466)
Utilizator | Data | 19 februarie 2024 18:20:52 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
string file="euclid2";
ifstream fin(file + ".in");
ofstream fout(file + ".out");
int main(){
int n;
fin >> n;
int a;
int b;
int c=1;
while (n--){
fin >> a;
fin >> b;
while(b){
c=a%b;
a=b;
b=c;
}
fout << a << '\n';
}
return 0;
}