Question: In C + + Implement the function bool getCoins ( int coins [ ] , int numCoins, int total, int s [ ] ) ;

In C++ Implement the function
bool getCoins(int coins[], int numCoins, int total, int s[]);
The function returns true if some subset of five "coins" from the coins array adds up to the given total. Otherwise the function returns false. If the function returns true then the first five elements of s will be populated with the indexes of coins that were used to make the given total.
For example
int coins[]={50,25,10,89,17,34,39,23,53,11,41,31};
int chosen[5];
bool found = getCoins(coins,12,238, chosen);
found would be set to true and the elements of chosen might be set to {35678}
Please explain each step thank you

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!