링크 : https://www.acmicpc.net/problem/15650
#include <iostream>
using namespace std;
#define MAX 9
int N, M;
int arr[MAX];
void dfs(int s, int len){
if(len == M){
for(int i = 0; i < len; i ++)
cout << arr[i] << ' ';
cout << '\n';
return;
}
for(int i = s; i <= N; i++){
arr[len] = i;
dfs(i+1, len+1);
}
}
int main(){
cin >> N >> M;
dfs(1, 0);
return 0;
}