Pagini recente » Diferente pentru utilizator/eu3neuom intre reviziile 15 si 16 | Diferente pentru preoni-2008/runda-finala intre reviziile 7 si 12 | Borderou de evaluare (job #95499) | Profil leo05 | Cod sursa (job #804401)
Cod sursa(job #804401)
#include<cstdio>
#include<bitset>
using namespace std;
FILE *f=fopen("permutari.in","r");
FILE *g=fopen("permutari.out","w");
int n,st[9];
bitset <9> ap;
void tipar(int k)
{int i;
for (i=1;i<=k;++i)
fprintf(g,"%d ",st[i]);
fprintf(g,"\n");
}
void back(int k)
{int i;
for (i=1;i<=n;++i)
{
st[k]=i;
if (ap[st[k]]==0)
{
ap[st[k]]=1;
if (k==n) tipar(k);
else back(k+1);
ap[st[k]]=0;
}
}
}
int main()
{fscanf(f,"%d",&n);
back(1);
return 0;
}