Cod sursa(job #266541)

Utilizator andy41pislaru andrei andy41 Data 25 februarie 2009 19:39:22
Problema Combinari Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
#include<fstream.h>
ifstream f("combinari.in");
ofstream g("combinari.out");
int st[50],n,k;
int valid(int x)
{int i;
for(i=1;i<x;i++)
	if(st[x]<=st[i])
		return 0;
  return 1;
  }
void tip(int k)
{int i;
for(i=1;i<=k;i++)
g<<st[i];

}

void back(int x)
{
int i;
for(i=st[x-1]+1;i<=n;i++)
{
st[x]=i;
//if(valid(x))
  if(x==k)
		tip(k);
	 else
	 back(x+1);
	 }
	 }
int main()
{
f>>n>>k;
st[0]=0;
back(1);
f.close();
g.close();
return 0;
}