Cod sursa(job #1424335)

Utilizator TeodorescuStefanEduardTeodorescu Stefan Eduard TeodorescuStefanEduard Data 24 aprilie 2015 00:05:12
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <iostream>
#include <fstream>

using namespace std;

fstream in("combinari.in",ios::in);
fstream out("combinari.out",ios::out);

int n,k,a[100]={};

void back(int);

int main()
{
	in>>n>>k;

	back(1);

	return 0;
}

void back(int x)
{
	int i;
	if(x>k)
	{
		for(i=1;i<=k;i++)
			out<<a[i]<<" ";
		out<<"\n";
	}
	else
	{
		if(x>1)
			a[x]=a[x-1];
		else
			a[x]=0;
		while(a[x]<n-k+x)
		{
			a[x]++;
			back(x+1);
		}
	}

}