Pagini recente » Cod sursa (job #848203) | Cod sursa (job #805841) | Cod sursa (job #2662078) | Cod sursa (job #2459971) | Cod sursa (job #3002076)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
///PRACTICE
using namespace std;
ifstream fin ("permutari.in");
ofstream fout ("permutari.out");
const int NMAX=10;
bool viz[NMAX];
int v[NMAX];
int n;
void backt(int k)
{
int i;
if(k==n+1)
{
for(i=1;i<=n;i++)
fout<<v[i]<<" ";
fout<<"\n";
}
else
{
for(i=1;i<=n;i++)
if(!viz[i])
{
viz[i]=true;
v[k]=i;
backt(k+1);
viz[i]=0;
}
}
}
int main()
{
int i;
fin>>n;
backt(1);
return 0;
}