알고리즘 풀이/백준
n과 m(1)
claire
2022. 3. 8. 12:29
#include<iostream>
using namespace std;
int board[10][10];
int n, m;
int arr[10];
bool isused[10];
void func(int k) {
if (k == m) {
for (int i = 0; i < m; i++) {
cout << arr[i] << ' ';
}
cout << '\n';
return;
}
for (int i = 1; i <= n; i++) {
if (!isused[i]) {
arr[k] = i;
isused[i] = 1;
func(k + 1);
isused[i] = 0;
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
func(0);
}