Pagini recente » Cod sursa (job #1881063) | Cod sursa (job #3228048) | Cod sursa (job #1672246) | Cod sursa (job #1844729) | Cod sursa (job #2193209)
#include<iostream>
#include<fstream>
using namespace std;
bool ireductibil(unsigned i, unsigned j)
{
unsigned min;
if (i < j)
min = i;
else
min = j;
if (i != 1 && j != 1)
for (unsigned z = 2; z <= min; z++)
if (i%z == 0 && j%z == 0)
return false;
return true;
}
int main()
{
unsigned n;
ifstream f("fractii.in");
f >> n;
f.close();
unsigned nr = 0, i, j;
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
if (ireductibil(i, j))
{
nr++;
cout << i << "/" << j << ' ';
}
ofstream g("fractii.out");
g << nr;
g.close();
cin.get();
}