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
A spherical seed of 1 cm diameter is buried at a depth of 1 cm inside soil (thermal conductivity of 1 Wm-1K-1) in a sufficiently
postnew [5]

Answer:

Find the attachment for the answer

8 0
3 years ago
Which crystal system(s) listed below has (have) the following relationship for the unit cell edge lengths?
lianna [129]

Answer:

Both B and G ( Hexagonal and Tetragonal )

Explanation:

The crystals system listed below has the following relationship for the unit cell edge lengths; a = b ≠ c ( hexagonal and Tetragonal )

hexagonal ; represents  a crystal system  which has three equal axes that have an angle of 60⁰ between them while Tetragonal denotes crystals that have  three axes which have only two of its axes equal in length.

5 0
3 years ago
Consider the velocity boundary layer profile for flow over u flat plate to be of the form u = C_1 + C_2 y. Applying appropriate
ra1l [238]

Answer:

The  result in terms of the local Reynolds number ⇒ Re = [μ_∞ · x] / v

Explanation:

See below my full workings so you can compare the results with those obtained from the exact solution.

4 0
4 years ago
If the slotted arm rotates counterclockwise with a constant angular velocity of thetadot = 2rad/s, determine the magnitudes of t
astraxan [27]

Answer:

Magnitude of velocity=10.67 m/s

Magnitude of acceleration=24.62 ft/s^{2}

Explanation:

The solution of the problem is given in the attachments

3 0
3 years ago
Hello, how are you? ​
Kisachek [45]

Answer:

Hello, I'm good. Thank you for asking

8 0
2 years ago
Read 2 more answers
Other questions:
  • What are the three main areas of bioengineering?
    11·1 answer
  • An immersion heater has a resistance of 50Ω and carries a current of 2.5A current. What will be the final temperature of 500 g o
    11·1 answer
  • WhT DO FILM PRODUTION SAY WHEN REMOVING GREEN AND BLUE SCREENS.
    14·1 answer
  • Give an example of how the fields of science, technology, and mathematics are commonly used when building a highway.
    7·1 answer
  • Who is the best musician in Nigeria<br>​
    11·2 answers
  • Water discharging into a 10-m-wide rectangular horizontal channel from a sluice gate is observed to have undergone a hydraulic j
    12·1 answer
  • (a) Sabbir usually (sit)______ in the front bench.
    13·1 answer
  • Resistors of 150 Ω and 100 Ω are connected in parallel. What is their equivalent resistance?
    13·1 answer
  • Sawzall® is another term commonly applied to?
    12·1 answer
  • 3. If nothing can ever be at absolute zero, why does the concept exist?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!