logo CodeStepByStep logo

waysToAverage

Language/Type: C++ recursion backtracking
Related Links:

Write a function named waysToAverage that accepts a reference to a vector of integers v and a target value k as parameters and returns the number of subsets of v that have an average element value of exactly k. For example, if v stores {7, 9, 8, 9} and k is 8, there are four subsets of v that have an average element value of 8: {8}, {7, 9}, {7, 9}, {7, 8, 9}, and {7, 8, 9}, so you should return 5.

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.