Cod sursa(job #1237967)

Utilizator Alex_dudeDudescu Alexandru Alex_dude Data 5 octombrie 2014 12:35:13
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <stdio.h>

using namespace std;
int x[100],n,m,use[100];

void afis()
{
    int i;
    for(i=1;i<=m;i++)
        printf("%d ",x[i]);
    printf("\n");
}
void back(int k)
{
    int i;
    if(k>m)afis();
    else
        for(i=k;i<=n;i++)
        if(i>x[k-1])
        {

            x[k]=i;
            back(k+1);

        }
}
int main()
{
  freopen("combinari.in","r",stdin);
  freopen("combinari.out","w",stdout);
  scanf("%d%d",&n,&m);
  back(1);
  return 0;
}

//Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.