๋ฌธ์
์ฝ๋
#include <iostream>
#include <vector>
#define max 8
using namespace std;
int N, M;
int arr[max];
bool visited[max];
void dfs(int start) {
if (start == M) {
for (int i = 0; i < M; i++) {
cout << arr[i] << ' ';
}
cout << "\n";
}
else {
for (int i = 1; i <= N; i++) {
visited[i] = true;
arr[start] = i;
visited[i] = false;
dfs(start + 1);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
dfs(0);
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 15655๋ฒ - N๊ณผ M (6) (0) | 2021.12.04 |
---|---|
[๋ฐฑ์ค,c++] 15654๋ฒ - N๊ณผ M (5) (0) | 2021.12.04 |
[๋ฐฑ์ค,c++] 15652๋ฒ - N๊ณผ M (4) (0) | 2021.12.04 |
[๋ฐฑ์ค,c++] 1405๋ฒ - ๋ฏธ์น ๋ก๋ด (0) | 2021.11.22 |
[๋ฐฑ์ค,c++] 1188๋ฒ - ์์ ํ๋ก ๊ฐ (0) | 2021.11.22 |
[๋ฐฑ์ค,c++] 15650๋ฒ - N๊ณผ M (2) (0) | 2021.11.17 |
๋๊ธ