std::next_permutationとstd::prev_permutationの練習
next_permutationとprev_permutationは順列を生成します。
#include <algorithm>
string s = "ABC";
while (next_permutation(s.begin(), s.end()))
{
puts(s.c_str());
}
結果
ABC
ACB
BAC
BCA
CAB
CBA
std::next_permutationとstd::prev_permutationの練習
next_permutationとprev_permutationは順列を生成します。
#include <algorithm>
string s = "ABC";
while (next_permutation(s.begin(), s.end()))
{
puts(s.c_str());
}
結果
ABC
ACB
BAC
BCA
CAB
CBA