같다. https://velog.io/@seochan99/15652-N-%EA%B3%BC-M-4 이사람 코드다.
유형을 익히자.
#include <stdio.h>
int n, m;
int result[1000];
void DFS(int depth, int cut)
{
int i;
if (depth == m)
{
for (int i = 0; i < m; i++)
printf("%d ", result[i]);
printf("\n");
}
else
{
for (i = 1; i <= n; i++)
{
if (cut <= i)
{
result[depth] = i;
DFS(depth + 1, i);
}
}
}
}
int main(void)
{
scanf("%d %d", &n, &m);
DFS(0, 0);
return 0;
}
16560에서 cut을 살리고 범위를 i이하로 수정해주면 된다