Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h.>
- #include <vector.h>
- using namespace std;
- int *tab;
- int N;
- void perm(int step){
- int tmp;
- if(step==0){
- cout<<endl;
- for(int i=0;i<N;i++)
- cout<<tab[i]<<" ";
- }
- else{
- for(int i=0;i<step;i++){
- tmp=tab[i];
- tab[i]=tab[step];
- tab[step]=tmp;
- perm(step-1);
- tmp=tab[i];
- tab[i]=tab[step];
- tab[step]=tmp;
- }
- }
- }
- void permut(int n){
- tab=new int [n+1];
- for (int i=0;i<n+1;i++)
- tab[i]=i;
- perm(n);
- }
- int main(){
- N=4;
- permut(N);
- getche();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement