Cod sursa(job #2471443)
Utilizator | Data | 10 octombrie 2019 21:41:07 | |
---|---|---|---|
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;
ifstream f ("ex.in");
ofstream g ("ex.out");
int main()
{
int x,y,c,n;
f>>n;
for(int i=0;i<n;i++){
f>>x;
f>>y;
while(x !=y){
if(x>y){
x=x-y;
}
else{
y=y-x;
}
}
g<<x<<endl;
}
return 0;
}