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
You are to design two CONCEPTUALLY different synchronous state machines (Mealy and Moore) that perform the task described below.
allochka39001 [22]
Answer:








Explanation:









I hope this helps!
3 0
3 years ago
a stem and leaf display describes two-digit integers between 20 and 80. for one one of the classes displayed, the row appears as
allochka39001 [22]

Answer:

  52, 50, 54, 54, 56

Explanation:

The "stem" in this scenario is the tens digit of the number. Each "leaf" is the ones digit of a distinct number with the given tens digit.

  5 | 20446 represents the numbers 52, 50, 54, 54, 56

8 0
3 years ago
Develop a chase plan that matches the forecast and compute the total cost of your plan. (Negative amounts should be indicated by
vladimir2022 [97]

Answer:

The answer for the question :

"Develop a chase plan that matches the forecast and compute the total cost of your plan. (Negative amounts should be indicated by a minus sign. Leave no cells blank - be certain to enter "0" wherever required. Omit the "$" sign in your response.)"

is explained in the attachment.

Explanation:

4 0
3 years ago
If you replace the text value in an associative dimension, the text value will not change when the
Nostrana [21]

Answer:

C

Explanation:

7 0
4 years ago
An engineering drawing shows the: (A) dimensions, tolerances, cost, and sales or use volume of a component.(B) dimensions, toler
Leto [7]

Answer:

(B) dimensions, tolerances, materials, and finishes of a component.

Explanation:

An engineering drawing :

  An  engineering drawing is a technical drawing which draws the actual component .

An engineering drawing shows

1. Materials

2.Dimensions

3.Tolerance

4.Finishes of a component

Engineering drawing does not shows any information about the cost of component.

So the option B is correct.

3 0
3 years ago
Other questions:
  • Briefly describe the purpose of specifying boundary conditions.
    7·1 answer
  • A furnace wall consisting of 0.25 m of fire clay brick, 0.20 m of kaolin, and a 0.10‐m outer layer of masonry brick is exposed t
    8·1 answer
  • In RSA Digital Signature, Suppose Bob wants to send a signed message (x = 4) to Alice. The first steps are exactly t eps are exa
    5·1 answer
  • Marcelo es muy bueno resolviendo adivinanzas y acertijos. Por eso, estaba totalmente disgustado cuando se dio cuenta de que no e
    12·1 answer
  • Consider the circuit below where R1 = R4 = 5 Ohms, R2 = R3 = 10 Ohms, Vs1 = 9V, and Vs2 = 6V. Use superposition to solve for the
    15·1 answer
  • When you arrive at an intersection with a stop sign in your direction, if there is no marked stop
    14·2 answers
  • Why does teachers grade things that are not due yet​
    13·2 answers
  • El tiempo hasta que falle un sistema informático sigue una distribución Exponencial con media de 600hs. (Utilice 3 decimales par
    13·1 answer
  • Which fields of engineering use fluid power? Explain how these fields make use of fluid power systems: water supply, agricultura
    10·1 answer
  • A distribution center is used in which of the following applications?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!