Question: Can someone please correct the small errors and make the program work. The language should be c++. Sample Output: 1 2 3 1 3 4

Can someone please correct the small errors and make the program work. The language should be c++.

Sample Output:

1 2 3 1 3 4 1 4 5 2 3 4 2 4 5 3 4 5

#include ; #include ;

// Function Prototype of the combination function void combination(vector myvect, vector solVect, int start, int end, int index, int r) ;

void displayCombination( vector myvect, int n , int r){ vector solVect[r] ; // Will temporarily store all Combination combination (myvect, solVect, 0, n-1 , 0, r); // Display combinations with temporary array }

void combination(vector myvect, vector solVect, int start, int end, int index, int r){ if (index == r){ for (int i = 0; i= r - index; i++ ){ solVect[index] = myvect[i] ; combination (myvect, solVect, i+1, end, index + 1, r); } }

int main (){ std::vector myvect = {1,2,3,4,5}; int r = 3 ; int n = (sizeof(myvect) / sizeof(myvect[0])) ; displayCombination ( myvect, n, r ); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!