1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zhenek [66]
3 years ago
14

/* Function findBestVacation * duration: number of vacation days * prefs: prefs[k] indicates the rate specified for game k * pla

n: array with 366 positions with the sequence of games * to be played over the year. In other words, * plan[k] indicates the game planned for day k (1

Engineering
1 answer:
alexira [117]3 years ago
3 0

Answer:

This is the C++ code for the above problem:

#include<bits/stdc++.h>

using namespace std;

int computeFunLevel(int start, int duration, int prefs[], int ngames, int plan[]) {

if(start + duration > 365) { //this is to check wether duration is more than total no. of vaccation days

return -1;

}

int funLevel = 0;

for(int i=start; i<start+duration; i++) { //this loop runs from starting point till

//start + duration to sum all the funlevel in plan.

funLevel = funLevel + prefs[plan[i]];

}

return funLevel;

}

int findBestVacation(int duration, int prefs[], int ngames, int plan[]) {

int max = 0, index = 0, sum = 0 ;

for(int i=1; i<11; i++){ //this loop is to run through whole plan arry

sum = 0; //sum is initialized with zero for every call in plan ,

//in this case loop should run to 366,but for example it is 11

//as my size of plan array is 11

for(int j=0; j<duration; j++) { // this loop is for that index to index+duration to calc

//fun from that index

sum = sum + prefs[plan[i]];

}

if(sum>max) { //this is to check max funlevel and update the index from which max fun can be achieved

max = sum;

index = i;

}

}

return index;

}

int main() {

int ngames = 5;

int prefs[] = { 1,2,0,5,2 };

int plan[] = { 0,2,0,3,3,4,0,1,2,3,3 };

int start = 1;

int duration = 4;

cout << computeFunLevel(start, duration, prefs, ngames, plan) << endl;

cout << computeFunLevel(start, 555, prefs, ngames, plan) << endl;

cout << findBestVacation(4, prefs, ngames, plan) << endl;

}

The screen of the program is given below.

You might be interested in
Q2) An engineer borrowed $3000 from the bank, payable in six equal end-of-year payments at 8%. The bank agreed to reduce the int
tatyana61 [14]
Answer is: $637.28; just did the math but i really don’t want to type it all out.
6 0
3 years ago
Which of the following uses pressure and flow to transmit power from one location to another?
lord [1]

Answer:

fluid power

Explanation:

fluids commonly used in fluid power are Oil, Water, Air, CO², and Nitrogen gas, fluid power is commonly confused with hydraulic power, which only uses liquids, fluid power uses either liquids or gases

5 0
2 years ago
What are 4 activities that you do in your daily life that DO require energy?
SashulF [63]

Answer: Some activities that I do in my daily life that require energy are:

1. Doing ballet

2. Studying

3. Walking up and down stairs

4. Stretching

5. Running on the treadmill

Hope this helps!  :)

Explanation:

4 0
3 years ago
In an ideal gas, specific enthalpy is a function of i. Entropy ii. Temperature iii, Pressure iv. Mass
Mice21 [21]

Answer:

Temperature

Explanation:

In an ideal gas the specific enthalpy  is exclusively a function of Temperature only this can be also written as h = h(T)  

A gas is said be ideal gas if obeys PV= nRT law

And in a ideal gas both internal energy and specific enthalpy are a function of Temperature only. Therefore the constant volume and constant pressure specific heats Cv and Cp are also function of temperature only.

5 0
3 years ago
Which of these passages is an example of cohesive writing?
Oksana_A [137]
The answer mostly likely is: “1” due to the fact it is well ordered, and follows a similar thought process, best of luck!
3 0
2 years ago
Read 2 more answers
Other questions:
  • 9. How is the Air Delivery temperature controlled during A/C operation?
    9·1 answer
  • A ductile hot-rolled steel bar has a minimum yield strength in tension and compression of 350 MPa. Using the distortion-energy a
    6·1 answer
  • Consider the following relational database that Best Airlines uses to keep track of its mechanics, their skills, and their airpo
    14·1 answer
  • What should -7/56 BE DIVIDE TO GET -1/8​
    14·2 answers
  • Omplete the following program: [0.5 X 4 = 2]
    11·1 answer
  • Solved this question??????????????????
    13·1 answer
  • Can someone help me plz!!! It’s 25 points
    6·2 answers
  • Characteristics of 3 types of soil​
    10·1 answer
  • What speeds did john j montgomerys gliders reach
    12·1 answer
  • Nec ________ covers selection of time-delay fuses for motor- overload protection.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!