Pagini recente » Cod sursa (job #2814366) | Cod sursa (job #2987324) | Cod sursa (job #2941106) | Cod sursa (job #1173430)
//#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
ifstream cin("permutari.in");
ofstream cout("permutari.out");
int n;
bool bl[10];
vector<char> c;
void perm(int x){
bl[x]=1;
if(c.size()==n){
for(int j=0;j<c.size();j++){
cout<<c[j]<<' ';
}
cout<<'\n';
}
for(int i=1;i<=n;i++){
if(!bl[i]){
c.push_back('0'+i);
perm(i);
}
}
bl[x]=0;
c.pop_back();
}
int main() {
cin>>n;
for(int i=1;i<=n;i++){
c.push_back('0'+i);
perm(i);
}
return 0;
}