목록등차 (1)
Game Tech Blog
알고리즘 교안 학습 -2 [순열, 조합, 정수론]
[순열 - 재귀 방식] 재귀 방식 커스텀 순열은 지겹도록 반복해서 코드를 외워버렸다. 이해하는 손 디버깅에도 반복했던 시간을 다하면 못해도 2시간이상은 할당했던것 같다. void permutation(int n, int r, int depth) { if (depth == r) { permutationPrint(); return; } for (int i = depth; i < n; ++i) { swap(a[i], a[depth]); permutation(n,r,depth+1); swap(a[i], a[depth]); } } void permutationPrint() { for (int i = 0; i < (sizeof(a) / sizeof(int)); ++i) cout
Algorithm
2023. 8. 30. 14:00