#include <bits/stdc++.h>
using namespace std;
//14888 ㄱㄱ
int n,m;
int arr[10];
int num[10];
void NM(int now_n,int last){
//기저
if(now_n==m) {
for(int i=0; i<m; i++) {
cout << arr[i] <<' ';
}
cout << '\n';
return;
}
for(int i=last; i<n; i++) {
arr[now_n]=num[i];
NM(now_n+1,i+1);
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i=0; i<n; i++) {
cin >> num[i];
}
//정렬
sort(num,num+n);
NM(0,0);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: