mhdew

All Combination

Apr 3rd, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool flag[100];
  6.  
  7. vector<int> v;
  8. int n=3;
  9.  
  10. void bt(int pos)
  11. {
  12.     if(pos>n){
  13.         for(int i=0;i<v.size();i++){
  14.             printf("%d ", v[i]);
  15.         }
  16.         printf("\n");
  17.         return;
  18.     }
  19.  
  20.     v.push_back(pos);
  21.     bt(pos+1);
  22.     v.pop_back();
  23.     bt(pos+1);
  24. }
  25.  
  26. int main()
  27. {
  28.     bt(1);
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment