Cod sursa(job #652160)

Utilizator Lokycatalin petre Loky Data 23 decembrie 2011 09:22:39
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>

using namespace std;

ifstream f("combinari.in");
ofstream g("combinari.out");


int n,k,st[20];

void back()
{
	int v,i;
	v=1;
	st[v]=0;
	while (v>0) {
	while (v<=k &&st[v]<n)
	{
		st[v]++;
		if (v==k) {
			for (i=1;i<=k;i++)
				g<<st[i]<<' ';
			g<<'\n';
		}
		else {
			v++;
			st[v]=st[v-1];
		}
	}
	--v;
	}
}
	
int main()
{
	
	f>>n>>k;
	back();
	f.close();
	g.close();
	return 0;
}