Pagini recente » Cod sursa (job #704327) | Cod sursa (job #2695472) | Cod sursa (job #1436877) | Cod sursa (job #443594) | Cod sursa (job #444357)
Cod sursa(job #444357)
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(long a, long b)
{
if(b==0 || a==0)
return 0;
long c;
while(b)
{
c = a%b;
a = b;
b = c;
}
return a==1?0:a;
}
int main()
{
int n;
ifstream fin("fractii.in");
ofstream fout("fractii.out",ios::out);
fin>>n;
int count=0;
for(int i=2;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
// both odd
if( (i & 0x1) == 0 &&
(j & 0x1) == 0)
{
continue;
}
if(j%i != 0 && i%j !=0)
{
if(cmmdc(i,j) ==0)
{
count ++;
cout<<i<<"/"<<j<<" ";
}
}
}
cout<<endl;
}
count += n + (n-1);
cout<<count;
fout<<count;
fin.close();
fout.close();
return 0;
}