Cod sursa(job #460855)

Utilizator AndreiRSStatescu Andrei Rares AndreiRS Data 4 iunie 2010 12:03:05
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <stdio.h>
#define DIMBACK 1<<5 

int X[DIMBACK];
int N, K;

void back (int k){
	int i;
	
	if (k - 1 == K){
		for (i=1; i<=K; i++)
			printf ("%d ", X[i]);
		printf ("\n");
		return;
	}	
	
	for (i = X[k-1] + 1; i<=N; i++){
		X[k] = i;
		back (k + 1);
	}	
}

int main (){
	
	freopen ("combinari.in", "r", stdin);
	freopen ("combinari.out", "w", stdout);
	
	scanf ("%d %d", &N, &K);
	
	back (1);
	
	return 0;
}