Answer the question
In order to leave comments, you need to log in
The last line of the array displays to me a lot of times, what's the problem?
THE CODE:
cout <<"--------------GenComb---------------"<<endl;
for (int i=0; i<n; i++)
a[i]=i+1;
for (int j=0; j<k; j++)
{
cout<<a[j]<<"";
}
cout<<endl;
while (n>k)
{
GenComb (a, n, k);
for (int j=0; j<k; j++)
{
cout <<a[j]<<"";
}
cout<<endl;
}
return 0;
}
3456
3456
3456
3456
3456
3456
3456
3456
3456
3456
3456
3456
Answer the question
In order to leave comments, you need to log in
If you take a closer look at your code, you will notice that there the output of the array a occurs in a loop while(n>k)
. Where exactly the error is is not clear, because it is not clear what your code should do. Either you inserted the output of the array in the wrong place, or GetComb
it does something wrong and the loop is executed more times than it should.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question