Cod sursa(job #1928011)

Utilizator alex273Groza Alexandru alex273 Data 15 martie 2017 19:51:33
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream> 
#include <fstream>
using namespace std; 
int k=0;
void ireductibil (int,int);
void fractii (int&);
ifstream f("fractii.in");
ofstream g("fractii.out");

   int main () 
{ int n;
f>>n;
fractii (n);
g<<k;
f.close ();g.close ();
return 0;
}

   void fractii (int& n)
{ int i,j;
for (i=1;i <=n;++i){ 
for (j=1;j<=n;++j)
ireductibil (i,j);}
}

   void ireductibil(int a,int b)
{
do
{if (a>b) { a=a-b; }
if (b>a) { b=b-a; }}
while (b != a);
if (a==1) k++ ;
}