Cod sursa(job #163947)

Utilizator xtremespeedzeal xtreme Data 23 martie 2008 12:48:50
Problema Combinari Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include<iostream.h>
#include<fstream.h>


int n,k,st[20],as,ev,i,h,j;

void succesor()
	{
	if(st[k]<n)
			{st[k]++;as=1;}
		else
			as=0;
	}
int main()
	{
	fstream f("combinari.in",ios::in),g("combinari.out",ios::out);
	f>>n>>h;
	k=1;st[k]=0;
	while(k>0)
		{
		succesor();
		if(as==1)
			{
			if(k==h)
				{
				for(i=1;i<=h;i++)
					g<<st[i]<<" ";
				g<<endl;

				}
			else
				{aux=st[k];k++;st[k]=aux;}
			}
		else
			k--;
		}
	f.close();g.close();
	}