Cod sursa(job #1495073)

Utilizator BlackREzRadut Alexandru Catalin BlackREz Data 2 octombrie 2015 15:36:46
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include <iostream>
#include <fstream>
using namespace std;
int algorithm(int x , int y){
    int z;
    z=x%y;
    x=y;
    y=z;
    if(y>0) algorithm(x , y);
    else return x;

}
int main()
{
    ifstream f("euclid2.in");
    ofstream g("euclid2.out");
    int x,y,n,i;
    f>>n;
    for(i=1;i<=n;i++){
    f>>x>>y;
    if(x<y) switch(x , y);
    g<<algorithm(x , y)<<'\n';
    }
    return 0;
}