You are on page 1of 4

/******************************************************************************

Online C++ Compiler.

Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int n , m , k , st[100] , ev , as;

void init()

st[k]=0;

int succesor()

if(st[k]<n)

{st[k]=st[k]+1;

return 1;

}
return 0;}

int valid(){

for(int i=1;i<k;i++)

if(st[k]==st[i])

return 0;

return 1;}

int solutie(){

return k==m;

void tipar(){

for(int i=1;i<=m;i++)

cout<<st[i]<<" ";

cout<<endl;

void bt()

k=1;

init();

while(k>0)

as=1;ev=0;

while(as && !ev)

as=succesor();

if(as)
ev=valid();

if(as)

if(solutie())

tipar();

else

k++;

init();

else

k--;

int main()

cout<<"n = ";

cin>>n;

cout<<"m = ";

cin>>m;

bt();
return 0;

You might also like