Cod sursa(job #1169752)

Utilizator Vele_GeorgeVele George Vele_George Data 11 aprilie 2014 23:22:32
Problema Algoritmul lui Euclid Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
using namespace std;

int euclid(int a, int b)
 {
   while (a!=0&&b!=0)
        if (a>b) a%=b;
           else  b%=a;
   return (a=0) ? a:b;

 }
int main()
{
   ifstream f("euclid2.in");
   ofstream g("euclid2.out");
    int T,a,b;

    f>>T;
    for(T=1;T<=3;T++)
     {
       f>>a;
       f>>b;
       g<<euclid(a,b)<<"\n";

     }

   return 0;
}