Cod sursa(job #2939166)
Utilizator | Data | 13 noiembrie 2022 10:19:35 | |
---|---|---|---|
Problema | Submultimi | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nr.in");
ofstream fout("nr.out");
int n,ap[20],st[20];
void Back(int k)
{
for(int x=1;x<=n;x++)
{
st[k]=x;
if(!ap[x] && !(k>1 && x<st[k-1]))
{
ap[x]=1;
for(int j=1;j<=k;j++)
cout << st[j] << " ";
cout << "\n";
Back(k+1);
ap[x]=0;
}
}
}
int main()
{
cin >> n;
Back(1);
return 0;
}