Cod sursa(job #328885)
Utilizator | Data | 3 iulie 2009 18:00:46 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include<iostream.h>
#include<fstream.h>
long cmmdc(long a,long b)
{if (b==0)
return a;
else
return cmmdc(b,a%b);
}
long n;
int main()
{ifstream fin("fractii.in");
fin>>n;
fin.close();
ofstream fout("fractii.out");
long i,j,nr;
nr=0;
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
if(cmmdc(i,j)==1)
{ fout<<i<<'/'<<j<<",";
nr++;
}
fout<<'\n';
}
fout<<nr;
fout.close();
return 0;
}