Pagini recente » Cod sursa (job #675235) | Cod sursa (job #1811606) | Cod sursa (job #2209363) | Cod sursa (job #2138685) | Cod sursa (job #2391122)
#include <bits/stdc++.h>
using namespace std;
ifstream f("permutari.in");
ofstream g("permutari.out");
int n,p[10];
void bkt(int);
int main()
{
f>>n;
bkt(1);
return 0;
}
void bkt(int i)
{
if(i==n+1)
{
for(int j=1;j<=n;j++)
g<<p[j]<<' ';
g<<'\n';
return;
}
for(int j=1;j<=n;j++)
{
bool gasit=false;
for(int k=1;k<i;k++)
if(p[k]==j)
gasit=true;
if(!gasit)
{
p[i]=j;
bkt(i+1);
}
}
}