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
Measures the power output of the machine
koban [17]
Watts I believe is the answer
4 0
3 years ago
Which regulations are related to guard rail height and dimensions and uniformity of stairs?
galina1969 [7]

Answer:

C.

structural safety

Explanation:

Guards protecting floor surfaces must be 36 inches in height, while guards for stairs must be 34 inches in height measured vertically from the tread nosing. A guard may also serve as the required handrail (34 to 38 inches high) provided the top rail meets the requirements for grip size.

4 0
4 years ago
Read 2 more answers
150 lb of force is applied at the end of a shaft that is 2 1/2 ft long. It is applied
Alona [7]

Answer:

Torque: 500

Power: 1700

Explanation:

Since the force is 150 lbs and if the shaft is rotating at 350 rpms, then you will need 1700 for the power in order to keep it running.

5 0
3 years ago
Technician A says power steering pumps can be engine driven. Technician B says power steering
ELEN [110]

Answer:

The correct option is;

C. Both A and B

Explanation:

Power steering supplies power more steering power when a driver turns the wheel to leverage the input steering effort of the driver thereby providing more steering with small effort

The power steering pumps which supply the power that to the fluid that eases steering of the wheel can be driven by the engine through a belt and pulley system or it can be installed in the front of the vehicle and from there, electrically driven alongside the refrigerant compressor

Therefore, both Technician A and Technician B are correct

7 0
3 years ago
A 50 kg diver stands motionless at the top of 10.0 meter high dive. What is her potential energy?
brilliants [131]

Answer:

Potential energy=4905 Joule

Explanation:

Potential energy is defined as the energy between two bodies due to its relative positions. Here one body is the diver and the other body is the earth. So acceleration will be the constant 9.81\ m/s^2

P.E.=m\times g\times h\\where\ m=mass\ of\ body=50\ kg\\g=acceleration\ due\ to\ gravity=9.81\ m/s^2\\h=height\ at\ which\ the\ body\ is\ from\ the\ ground=10.0\ m\\\Rightarrow P.E.=50\times 9.81\times 10.0\\\therefore Potential\ Energy=4905\ Joule

7 0
4 years ago
Other questions:
  • The hull of a vessel develops a leak and takes on water at a rate of 57.5 gal/min. When the leak is discovered the lower deck is
    9·1 answer
  • A vapor-compression refrigeration cycle operates at steady state with Refrigerant 134a as the working fluid. Saturated vapor ent
    11·1 answer
  • A vacuum gage connected to a chamber reads 35 kPa at a location where the atmospheric pressure is 92 kPa. The absolute pressure
    12·1 answer
  • The efficiency of a transformer is mainly dependent on: a)- Core losses b)- Copper losses c)- Stray losses d)- Dielectric losses
    12·1 answer
  • Technician A says a limited slip differential can redirect power from a drive wheel that is slipping to the wheel that has tract
    15·1 answer
  • Two airstreams are mixed steadily and adiabatically. The first stream enters at 35°C and 30 percent relative humidity at a rate
    6·1 answer
  • A has a mass of 7 kg, object B has a mass of 5 lbm, and object C has a mass of 0.5 slug. (a) Which object has the largest mass?
    11·1 answer
  • 13. What two major safety problems does hydrogen present?
    8·2 answers
  • How to solve circuit theory using mesh analysis<br>​
    11·1 answer
  • A building permit allows a builder to?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!