#include <algorithm>
#include <iostream>
#include <vector>

void print(const std::vector<int>& v)
{
    for (int e : v) {
        std::cout << " " << e;
    }
    std::cout << std::endl;
}

int main()
{
    std::vector<int> v = {1,2,3};
    // vector should be sorted at the beginning.

    do {
        print(v);
    } while (std::next_permutation(v.begin(), v.end()));
}