[백준] 📂. (15656번) N과 M (7)
🗒️ 15656번) N과 M (7)
#include <iostream>
#include <algorithm>
using namespace std;
int arr[8];
int selIdx[8];
int N, M;
void Sequence(int count)
{
if (count == M)
{
for (int i = 0; i < M; i++)
cout << arr[selIdx[i]] << ' ';
cout << '\n';
return;
}
for (int i = 0; i < N; i++)
{
selIdx[count] = i;
Sequence(count + 1);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> M;
for (int i = 0; i < N; i++)
cin >> arr[i];
sort(arr, arr + N);
Sequence(0);
return 0;
}
댓글남기기