Cod sursa(job #219287)
Utilizator | Vidovici Adelina adelinav | Data | 6 noiembrie 2008 12:21:37 |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include<stdio.h>
int st[100],n,m;
void scrie(){
int i;
for(i=1;i<=m;i++)
printf("%d ",st[i]);
printf("\n");
}
void bkt(){
int up,k;
k=1;
st[k]=0;
while(k){
up=0;
while(!up&&st[k]<n-k+m) {
st[k]++;
up=1;
}
if(up)
if(k==m) scrie();
else {k++;st[k]=st[k-1];}
else k--;
}
}
int main(){
freopen("combinari.in","r",stdin);
scanf("%d %d",&n,&m);
freopen("combinari.out","w",stdout);
bkt();
return 0;
}