Cod sursa(job #154170)

Utilizator sima_cotizoSima Cotizo sima_cotizo Data 10 martie 2008 22:50:55
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <cstdio>

long St[30],n,k;

void back(long p) {
	if ( p==k ) {
		for (long i=0; i<k; ++i)
			printf("%ld ", St[i]);
		printf("\n");
		return ;
	}
	for ( St[p]=1; St[p]<=n; ++St[p] )
		if ( St[p]>St[p-1] ) {
			back(p+1);
		}
}

int main() {
	fscanf(fopen("combinari.in", "r"), "%ld %ld", &n, &k);

	freopen("combinari.out", "w", stdout);
	back(0);
	return 0;
}