Pagini recente » Cod sursa (job #2068474) | Cod sursa (job #194936) | Cod sursa (job #1008841) | Cod sursa (job #937025) | Cod sursa (job #2209942)
#include <fstream>
using namespace std;
int CMMDC(int P,int Q)
{
int r=P%Q;
while(r!=0)
{
P=Q;
Q=r;
r=P%Q;
}
return Q;
}
void fractii_ireductibile(int &N)
{
int P,Q;
ifstream fin("fractii.in");
fin>>N;
fin.close();
ofstream fout("fractii.out");
for(P=1;P<=N;P++)
for(Q=1;Q<=N;Q++)
if(P==1)
fout<<P<<"/"<<Q<<" ";
else if(P>1 && Q==1)
fout<<P<<"/"<<Q<<" ";
else if(CMMDC(P,Q)==1)
fout<<P<<"/"<<Q<<" ";
fout.close();
}
int main()
{
int N;
fractii_ireductibile(N);
return 0;
}