C ++ Newbie potrzebuje pomaga w drukowaniu kombinacji liczb całkowitych

Przypuśćmy, że dano mi:

Zakres liczb całkowitychiRange (tj. od1 aż doiRange) iŻądana liczba kombinacji

Chcę znaleźć liczbę wszystkich możliwych kombinacji i wydrukować wszystkie te kombinacje.

Na przykład:

Dany: iRange = 5 in = 3

Wtedy liczba kombinacji jestiRange! / ((iRange!-n!)*n!) = 5! / (5-3)! * 3! = 10 kombinacje, a wyjście to:

123 - 124 - 125 - 134 - 135 - 145 - 234 - 235 - 245 - 345

Inny przykład:

Dany: iRange = 4 in = 2

Wtedy liczba kombinacji jestiRange! / ((iRange!-n!)*n!) = 4! / (4-2)! * 2! = 6 kombinacje, a wyjście to:

12 - 13 - 14 - 23 - 24 - 34

Moja dotychczasowa próba to:

#include <iostream>
using namespace std;

int iRange= 0;
int iN=0;

int fact(int n)
{
    if ( n<1)
        return 1;
    else
    return fact(n-1)*n;
}

void print_combinations(int n, int iMxM)
{
    int iBigSetFact=fact(iMxM);
    int iDiffFact=fact(iMxM-n);
    int iSmallSetFact=fact(n);
    int iNoTotComb = (iBigSetFact/(iDiffFact*iSmallSetFact));
    cout<<"The number of possible combinations is: "<<iNoTotComb<<endl;
    cout<<" and these combinations are the following: "<<endl;


    int i, j, k;
    for (i = 0; i < iMxM - 1; i++)
    {
        for (j = i + 1; j < iMxM ; j++)
        {
            //for (k = j + 1; k < iMxM; k++)
                cout<<i+1<<j+1<<endl;
        }
    }
}

int main()
{
    cout<<"Please give the range (max) within which the combinations are to be found: "<<endl;
    cin>>iRange;
    cout<<"Please give the desired number of combinations: "<<endl; 
    cin>>iN;
    print_combinations(iN,iRange);
    return 0;   
}

Mój problem: Część mojego kodu związana z drukowaniem kombinacji działa tylko dlan = 2, iRange = 4 i nie mogę sprawić, żeby działało ogólnie, tj. dla każdegon iiRange.

questionAnswers(5)

yourAnswerToTheQuestion