Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c + + implement the function bool getCoins ( int coins , int numCoins, int total, int s ) ; The function returns true

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. Note that we do not require the values in coins to be of the usual denominations; each coin can be any positive whole number.
Example
q,
int coins []={50,25,10,89,17,34,39,23,53,11,41,31} :
int chosen[5];
bool found = getCoins(coins,12,238, chosen):
q,
found would be set to true and the elements of chosen might be set to )
Absolutely no function calls and no material beyond Chapter 8 of the textbook.
To get credit. your code should not be overly long or complicated. Around 10 lines of code should be enough.
Copy paste a program with your function and a main that tests it extensively. Also copy paste your output from a sample run.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Describe three ways in which investors can use stock options.

Answered: 1 week ago

Question

Describe several models for organizing a human resources department

Answered: 1 week ago

Question

2. How will the team select a leader?

Answered: 1 week ago