Advertisement
Debashish_Saha

Untitled

Dec 10th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int used[5],p[5];
  4. void permut(int pos) {
  5.     if(pos>4) {
  6.         for(int i=1; i<=4; i++) {
  7.             printf("%d ",p[i]);
  8.         }
  9.         printf("\n");
  10.         return;
  11.     }
  12.     for(int i=1; i<=4; i++) {
  13.         if(used[i]==0) {
  14.             p[pos]=i;
  15.             used[i]=1;
  16.             permut(pos+1);
  17.             used[i]=0;
  18.         }
  19.     }
  20. }
  21. int main() {
  22.     permut(1);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement