Cod sursa(job #268386)

Utilizator marcuMarcu Cornel marcu Data 1 martie 2009 11:02:58
Problema Combinari Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include<stdio.h>
int x[20],n,k;
void readd(),afisare(),back(int poz);
int main()
{
	readd();
	back(1);
	return 0;
}
void readd()
{
	freopen("combinari.in","r",stdin);
	freopen("combinari.out","w",stdout);
	scanf("%d%d", &n,&k);
}
void back(int poz)
{
	int i;
	if(poz==k+1){afisare();return;}
	for(i=x[poz-1]+1;i<=n-1+poz;i++)
	{x[poz]=i;back(poz+1);}
}
void afisare()
{
	int i;
	for (i=1;i<=k;i++)
	printf("%d", x[i]);
	printf("/n");
}