1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include<cstdio> int n; int arr[10]; bool check[10]; void suyeol(int cnt) { if(cnt==n) { for(int i=0; i<n; i++) printf("%d ", arr[i]); printf("\n"); return; } for(int i=1; i<=n; i++) { if(!check[i]) { check[i]=true; arr[cnt]=i; suyeol(cnt+1); check[i]=false; } } } int main(void) { scanf("%d", &n); suyeol(0); return 0; } | cs |
'백준 2 > 완전탐색' 카테고리의 다른 글
| [백준 10971] 외판원 순회2 (0) | 2020.12.07 |
|---|---|
| [백준 2309] 일곱 난쟁이 (C++/Python) (0) | 2020.12.07 |
| [백준 10819] 차이를 최대로 (0) | 2020.12.07 |
| [백준 17141] 연구소 2 (0) | 2020.12.07 |
| [백준 1182] 부분수열의 합 (C++/Python) (0) | 2020.12.07 |