0

Possible Duplicate:
combination and permutation in C++

I have a vector of say size "n". Lets say for example a vector of n=4, <1,2,3,4>. How can I generate all n-1 combinations of this vector. In this example, 4 chose 3. I want the output to be <1,2,3> <1,2,4> <1,3,4> <2,3,4>. Thanks.

Community
  • 1
  • 1
0x0
  • 2,915
  • 5
  • 40
  • 67
  • 1
    Duplicate of [combination and permutation in C++](http://stackoverflow.com/questions/2211915/combination-and-permutation-in-c), especially Charles Bailey's awesome solution. – James McNellis Mar 08 '11 at 04:40
  • There are as many `n-1` combinations of elements as `n`-combinations. Only the remaining element is not present. Keep that in mind. – Benoit Mar 08 '11 at 04:55
  • Thanks for the link. I've voted to close as well. – 0x0 Mar 08 '11 at 05:11

1 Answers1

2

Start by looking up STL's next_permutation function.

Steve
  • 1,760
  • 10
  • 18