Pagini recente » Cod sursa (job #2947036) | Cod sursa (job #2814724) | Cod sursa (job #2655019) | Cod sursa (job #2698731) | Cod sursa (job #1173428)
//#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;
}