Advertisement
jthill

Generate all combinations of the option strings

Dec 19th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6. int main(int c, const char **v)
  7. {
  8.     basic_string<const char *> options(v);
  9.     auto N(options.length());
  10.     for (auto n = 1u; n < N; ++n) {
  11.         vector<char> pick(N);
  12.         fill_n(pick.rbegin(), n, 1);
  13.         do for (auto j=1u; j<N; ++j)
  14.             if (pick[j])
  15.                 cout << options[j]<<' ';
  16.         while (cout<<'\n', next_permutation(begin(pick)+1, end(pick)));
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement