[C++ 줍줍] next_permutation과 순열/조합
1. header #include 2. 순열 next_permutation(v.begin(), v.end()) ex. v = {1, 2, 3, 4} (1) 입력 벡터가 다음 순열로 바뀌면서 true를 리턴 : v={1, 2, 4, 3}, true 리턴 (2) 마지막 순열까지 모두 바뀌었다면 false를 리턴 : v={4, 3, 2, 1}, false 리턴 따라서, (1)때문에 while문이 아닌 do-while문을 사용해야 하고 (처음 자신 포함하려고) (2)때문에 while문 조건문이 next_permutation이 된다. void permutation() { int arr[] = { 1, 2, 3, 4 }; do { for (int i = 0; i < 4; i++) { cout
2022. 9. 20.