Advertisement
zhukov000

Permutation Example

Dec 12th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. void show(const vector<int> & b)
  5. {
  6.   for(int i=0; i<b.size(); ++i) cout << b[i];
  7.   cout << endl;
  8. }
  9.  
  10. int main() {
  11.   int n, k, i=0;
  12.   cin >> n >> k;
  13.   vector<int> a(n, 0);
  14.   for(i = n-k; i<n; ++i) a[i] = 1;
  15.   do
  16.   {
  17.     show(a);
  18.   } while(next_permutation(a.begin(), a.end()));
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement