Cod sursa(job #1411802)

Utilizator jurjstyleJurj Andrei jurjstyle Data 31 martie 2015 22:37:51
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

int x[10] , n , k ;

ifstream fin ("combinari.in") ;
ofstream fout ("combinari.out") ;

int OK(int l)
{
	for(int i = 1 ; i < l ; ++i )
		if( x[i] >= x[i+1] )
			return 0 ;
	return 1 ;
}

void back(int l)
{
	for(int i = 1 ; i <= n  ; ++i )
	{
		x[l] = i ;
		if( OK (l) )
			if( l == k )
			{
				for( int j = 1 ; j <= k ; ++j )
					fout << x[j] << " " ;
				fout << "\n" ;
			}
			else
				back( l + 1 ) ;
	 }
}
int main()
{

    fin >> n >> k ;

	back(1) ;

	fin.close();
	fout.close();

	return 0;

}