Cod sursa(job #2282337)
Utilizator | Micu Cristian Mihai chryss | Data | 13 noiembrie 2018 17:12:37 |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main ()
{
ifstream f("euclid2.in");
ofstream g("euclid2.out");
int T,a,b,r;
f>>T;
while(f>>a>>b){
if(a<b)
{
r=a;
a=b;
b=r;
}
while(a%b!=0)
{
r=a%b;
a=b;
b=r;
}
if(b!=1)
g<<b;
else
g<<0;
}
return 0;}