#include <stdio.h>
using namespace std;

int n, r;
int check[20];

void DFS(int s, int L){
	if(L==r){
		for(int j=0; j<L; j++){
			printf("%d ", check[j]);
		}
		printf("\n");
	} else{
		for(int i=s; i<n; i++){
			check[L] = i;
			DFS(i+1, L+1);
		}
	}
}
int main(){
	freopen("input.txt", "rt", stdin);
	scanf("%d %d", &n, &r);
	DFS(0, 0);
	
	return 0;
}

input
6 4

output
0 1 2 3
0 1 2 4
0 1 2 5
0 1 3 4
0 1 3 5
0 1 4 5
0 2 3 4
0 2 3 5
0 2 4 5
0 3 4 5
1 2 3 4
1 2 3 5
1 2 4 5
1 3 4 5
2 3 4 5

+ Recent posts