Cod sursa(job #2011235)
Utilizator | Data | 15 august 2017 17:45:01 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <cstdio>
using namespace std;
int n,k,s[20];
void bak(int top)
{
int i;
if(top==k+1)
{
for(i=1;i<=k;i++)
printf("%d ",s[i]);
printf("\n");
return;
}
for(i=s[top-1]+1;i<=n;i++)
{
s[top]=i;
bak(top+1);
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d%d",&n,&k);
bak(1);
return 0;
}