Cod sursa(job #158091)
| Utilizator | Data | 13 martie 2008 14:02:44 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <cstdio>
int x[20],n,k,i,j=1;
int main(){
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d %d",&n,&k);
for (i=1;i<=k;i++) x[i]=i;
while (j>0) {for (i=1;i<=k;i++) printf("%d ",x[i]);
printf("\n");
j=k;
while (x[j]==n-k+j) j--;
if (j>0) {x[j]++;
for (i=j+1;i<=k;i++) x[i]=x[i-1]+1;}
}
fclose(stdout);
return 0;
}
