#include <iostream> #include <algorithm> #include <vector> int main() { int n, r; n = 10; r = 2; std::vector<bool> v(n); std::fill(v.end() - r, v.end(), true); std::vector< std::vector<int> > sequence_vector; do { std::vector<int> sequence; for (int i = 0; i < n; ++i) { if (v[i]) { std::cout << (i + 1) << " "; sequence.push_back(i+1); } } std::cout << " "; sequence_vector.push_back(sequence); } while (std::next_permutation(v.begin(), v.end())); std::cout<<"from vector"<<std::endl; std::vector<int>::iterator iterator_sequence; std::vector< std::vector<int> >::iterator iterator_sequence_vector; for(iterator_sequence_vector = sequence_vector.begin(); iterator_sequence_vector != sequence_vector.end(); iterator_sequence_vector++){ for (iterator_sequence = (*iterator_sequence_vector).begin(); iterator_sequence != (*iterator_sequence_vector).end(); iterator_sequence++){ std::cout<<*iterator_sequence<<" "; } std::cout<<std::endl; } return 0; }