std::next_permutationとstd::prev_permutationの練習

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

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください