Do in C++ programming A game to collecting coins. In level # 1, whenever the player takes a coin, the next coin is automatically blocked with an iron brick. Which coins should

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question

Do in C++ programming

A game to collecting coins. In level # 1, whenever the player takes a coin, the next coin is automatically blocked with an iron brick. Which coins should the player take in order to maximize his gains?

EXAMPLE:
COINS IN ORDER 3$  9$  2$  7$  3$  6$  9$  1$ 

START COLLECTING COINS =  (SKIP 3$)  (TAKE 9$)  (AUTOMATICALLY BLOCKED 2$)  (TAKE 7$)  (AUTOMATICALLY BLOCKED 3$)  (SKIP 6$)  (TAKE 9$)  (AUTOMATICALLY BLOCKED 1$) = TOTAL COINS WILL BE 25$ (max coins)

In level # 2, the same rules of level 1 apply, but with a twist:

the player have a bag that can take only a limited number of coins. Which coins can the player take in order to maximize his gains (provided that the coins fit inside his bag)?

Implement the following function for level# 2 using C++:

unsigned max_coins(vector<unsigned> coins, unsigned capacity)

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT