#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <iostream>
void output_sentence(const std::vector<std::string>& words, const std::vector<std::size_t>& indices)
{
bool space{ false };
for (const auto index : indices)
{
if (space) std::cout << " ";
std::cout << words[index];
space = true;
}
std::cout << "\n";
}
int main()
{
std::vector<std::string> words{ "I","Am","Coding" }; // vector with words;
std::vector<std::size_t> indices(words.size()); // vector of indices to permutate
std::iota(indices.begin(), indices.end(), 0ul); // fill indices from 0 to words.size()-1
do
{
output_sentence(words, indices);
} while (std::next_permutation(indices.begin(),indices.end())); // permutate indices
return 0;
}