Advertisement
DrBoat

Untitled

Jan 23rd, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. bool next_combination(vector<int> &a, int n) {
  7.     for (int i = a.size() - 1; i >= 0; i--)
  8.         if (a[i] < n - a.size() + i + 1) {
  9.             a[i]++;
  10.             for (int j = i + 1; j < a.size(); j++)
  11.                 a[j] = a[j - 1] + 1;
  12.             return true;
  13.         }
  14.     return false;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement