bool next_permutation(Iterator first, Iterator last)
vector<int> v = {2, 3, 1};
next_permutation(v.begin(), v.end());
for (int x : v) cout << x << ' '; // 출력: 3 1 2
bool prev_permutation(Iterator first, Iterator last)
vector<int> v = {2, 3, 1};
prev_permutation(v.begin(), v.end());
for (int x : v) cout << x << ' '; // 출력: 2 1 3
vector<int> v = { ... }; // 오름차순 정렬된 벡터
do {
// 현재 순서를 이용한 연산 수행
} while(next_permutation(v.begin(), v.end());