컴/알고리즘

C++ - next_permutation

gusud 2020. 4. 16. 00:45
#include <algorithm>

void nextPermutaionTest(vector<int> data) {
    sort(data.begin(), data.end());

    do {
        ///// 데이터 처리 ///////
    } while (next_permutation(data.begin(), data.end()));
}

이런 식으로 쓰면 된다 (iterator 대신 배열 주소 넣어도 됨)