Pagini recente » Cod sursa (job #1073050) | Cod sursa (job #2206692) | Istoria paginii runda/agm | Cod sursa (job #1682386) | Cod sursa (job #2924757)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("permutari.in");
ofstream fout("permutari.out");
int n, per[10];
bool vf[10];
void BACK(int depth);
int main()
{
fin >> n;
BACK(1);
return 0;
}
void BACK(int depth){
for(int i = 1; i <= n; i++){
if(vf[i] == 0){
per[depth] = i;
vf[i] = 1;
if(depth == n){
for(int j = 1; j <= n; j++){
fout << per[j] << ' ';
}
fout << '\n';
}else{
BACK(depth+1);
}
vf[i] = 0;
}
}
}