COMBINARI ITERATIV
#include<iostream.h>#include<conio.h>#include<math.h>int st[20],n,k,p; void init(){ if(k>1) st[k]=st[k-1]; else st[k]=0; } int succesor(){if (st[k]<n-p+k) {st[k]++; return 1; }else return 0;} int valid(){return 1;} int sol(){return (k==p);} void tipar(){for(int i=1;i<=p;i++) cout<<st[i];cout<<endl;} void bkt(){int as;k=1;init();while(k>0){do {} while ((as=succesor()) && !valid());if (as) if (sol()) tipar(); else {k++;init();}else k–;}} void main(){cout<<“n=”;cin>>n;cout<<“p=”;cin>>p;bkt();getch();} {joscommentenable}