combinari

//combinari#include<iostream.h>int st[20],n,k; void init(){int i;cout<<“n=”;cin>>n;cout<<“k=”;cin>>k;st[0]=0;} void tipar(int p){int j;for(j=1;j<=p;j++)cout<<st[j]<<” “;cout<<endl;} int solutie(int p){return (p==k);} void bkt(int p){int val;for (val=st[p-1]+1;val<=n;val++){st[p]=val;if(solutie(p))tipar(p);elsebkt(p+1);}} void main(){init();bkt(1);} {joscommentenable}

combinari

//combinari#include<iostream.h>#include<conio.h> long comb(int n,int k){if (k==0)  return 1;else if (k>n) return 0; else return (comb(n-1,k)+comb(n-1,k-1));} void main(){int k,n;cout<<“n=”;cin>>n;cout<<“k=”;cin>>k;cout<<//”combinari de”<<n<<“elemente luate cate”<<k<<“:”<<comb(n,k)<<endl;getch();} {module orizontal600}