Cod sursa(job #353880)
Utilizator | Data | 6 octombrie 2009 17:32:55 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include<iostream.h>
#include<stdio.h>
int p,n,st[100];
void back(int k)
{
int i;
if(k==p+1)
{
for(i=1;i<=p;i++)
printf("%d ",st[i]);
printf("\n");
}
else
{
if(k>1) st[k]=st[k-1];
else st[k]=0;
while(st[k]<n-p+k)
{
st[k]++;
back(k+1);
}
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d %d\n",&n,&p);
back(1);
return 0;
}