std::vector<int> v(N); std::iota(v.begin(), v.end(), 0); do { for (int x : v) std::cout << x; std::cout<<std::endl; } while(next_permutation(v.begin(), v.end()));