Mai intai trebuie sa te autentifici.
Cod sursa(job #1415296)
| Utilizator | Data | 4 aprilie 2015 10:35:09 | |
|---|---|---|---|
| Problema | Generare de permutari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include<iostream>
#include<fstream>
using namespace std;
fstream fin("permutari.in",ios::in),fout("permutari.out",ios::out);
int x[100],ap[100],a[100],n;
void scrie()
{
for(int i=1;i<=n;i++)
{
fout<<x[i]<<" ";
}
fout<<"\n";
}
void back(int k)
{
if(k>n)
{
scrie();
return ;
}
for(int i=1;i<=n;i++)
{
if(ap[i]==0)
{
ap[i]=1;
x[k]=i;
back(k+1);
ap[i]=0;
}
}
}
int main()
{
fin>>n;
back(1);
}
