1.函数 std::next_permutation(first, last)
2.用法的前提下是序列在有序的情况下;
#include <algorithm>
#include <string>
#include <iostream>
int main()
{
std::string s = "abc";
std::sort(s.begin(), s.end());
do {
std::cout << s << '\n';
} while(std::next_permutation(s.begin(), s.end()));
}
/*
output:
abc
acb
bac
bca
cab
cba
*/