Pagini recente » Profil gabybrezoiu | Infoarena Monthly 2014 - Solutii Runda 2 | Monitorul de evaluare | Cod sursa (job #3292868) | Cod sursa (job #3284450)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("permutari.in");
ofstream fout("permutari.out");
int n;
bitset<10001> fr;
int st[1005];
void Afis(int n)
{
for(int i = 1; i <= n; i++)
fout << st[i] << " ";
fout << "\n";
}
void Back(int top)
{
if(top == n + 1)
Afis(n);
else for(int i = 1; i <= n; i++)
if(fr[i] == 0)
{
fr[i] = 1;
st[top] = i;
Back(top + 1);
fr[i] = 0;
}
}
int main()
{
ios_base::sync_with_stdio(0);
fin.tie(0);
fout.tie(0);
int i,j;
fin >> n;
Back(1);
return 0;
}