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
Andrej [43]
4 years ago
11

github Portfolio Balances An investor opens a new account and wants to invest in a number of assets. Each asset begins with a ba

lance of o, and its value is stored in an array using 7-based indexing. Periodically, a contribution is received and equal investments are made in a subset of the portfolio. Each contribution will be given by investment amount, start index, end index. Each investment in that range will receive the contribution amount. Determine the maximum amount invested in any one investment after all contributions
Computers and Technology
1 answer:
OLEGan [10]4 years ago
6 0

The following code will be used to determine the maximum amount invested

<u>Explanation:</u>

long maxValue(int n, int rounds_rows, int rounds_columns, int into rounds)

{

   // Define the variable to store

   // the maximum amount invested.

   long max = 0;

   

   // Define an array of size n,

   // to store the n investments.

   long *investments = (long*)malloc(sizeof(long)*n);

   int i=0;  

   // Initially set all

   // the investments to 0.

   for(i=0;i<n;i++)

   {

       investments[i] = 0;

   }

   i=0;

   // Run the loop to

   // perform the rounds.

   while(i<rounds_rows)

   {

       // Get the left value

       // of the current round.

       int left = rounds[i][0];

       

       // Get the right value

       // of the current round.

       int right = rounds[i][1];

       // Get the contribution

       // for the current round.

       int contribution = rounds[i][2];

       // Since the user uses 1-based

       // indexing, subtract 1 from left

       // and right as the program uses

       // 0-based indexing. That is, the

       // investments in the array start

       // from 0 and not 1.

       right = right - 1;

       int j=0;

       // Run the loop to add the

       // contribution to all the investments

       // between left and right, both inclusive.

       for(j=left; j<=right; j++)

       {

           investments[j] += contribution;

       }

       i++;

   }

   // Traverse the investments array

   // to find the maximum element.

   max = investments[0];

   for(i=1; i<n;i++)

   {

       if(investments[i]>max)

       {

           max = investments[i];

       }

   }

   // Return the

   // maximum investment.

   return max;  

}

You might be interested in
Assuming you have a TCF free student checking account, how many maximum overdraft fees can you incur in one day?
kodGreya [7K]

Answer:

8

Explanation:

7 0
3 years ago
Write a program that inputs a line of text and uses a stack object to print the line reversed.
Lina20 [59]

Answer:

#include <bits/stdc++.h>

using namespace std;

int main() {

   string ms;

   getline(cin,ms);

   stack<char>st;

   for(int i=0;i<ms.length();i++)//Inserting every element in the stack..

   {

       st.push(ms[i]);

   }

   while(!st.empty()) //doing operation until the stack is not empty..

   {

       char a=st.top();//accessing the top element of the stack...

       st.pop();//removing the head.

       cout<<a;//printing the character..

   }

return 0;

}

Input:-

murder

Ouput:-

redrum

Explanation:

An  easy way to reverse anything is to use stack.Since stack is LIFO type data structure so the last item in will be the first one to get out hence it reverses the elements.So inserting every element of the string into the stack of characters and then printing the every element of the stack from top to bottom.

8 0
3 years ago
what is the primary way to access applications in windows 8? a. control panel b. start menu c. desktop tiles d. context menu
kow [346]
In Windows 8, when you hit the Windows icon (in previous versions known as the start menu) it takes you to a separate page of tiles where all your applications and programs are. The easiest way to access your most needed programs and files is to create a shortcut on your desktop. This makes C. Desktop Tiles your primary way to access applications
6 0
3 years ago
A disk takes 1 ms per track seek time, and the head is currently on track 70. Assume it takes 5 ms to service a request once the
Andreyy89

Answer:

Total time = 190 ms

Explanation:

The requests missing in question are:

Requests ( A, 80) , (B,75) , (C,82) , (D,90) , (E,45)

Number of movements = | 70 - 45 | +  | 45 - 0 | +  | 0 - 75 | +  | 75 - 80 | +  | 80 - 82 | +  | 82 - 90 |

= 35 + 45 + 75 + 5 + 2 + 8

= 70 + 80 + 10

= 160

Time taken for seek = 160 * 1 ms = 160 ms

Time taken for servicing request = Number of tracks * Time for each track = 5*6 = 30

Total time = 160 + 30 = 190 ms.  

7 0
4 years ago
Who is good with Introduction to photography? I don’t know nothing about cameras if you do please contact me ASAP
son4ous [18]

ok i can help you with your questions

5 0
3 years ago
Other questions:
  • If a user has just added a simple triangle shape into a diagram, how can the triangle be adjusted? Check all that apply. by maki
    6·2 answers
  • Within the Chart Design tab, which section is used to change the data of a previously created chart?
    12·1 answer
  • How many pounds must a sand bag weigh to test if a safety net can absorb the proper amount of force? A. 150 lbs. B. 200 lbs. C.
    6·1 answer
  • Match the desired outcome to the appropriate action.
    6·1 answer
  • Please hurry!
    15·2 answers
  • What is the answer???​
    6·1 answer
  • What method of thermal energy is at work when heat lamps are used to warm up baby chickens?
    11·2 answers
  • . Write at least three benefits of using a network.​
    8·1 answer
  • What is the output for this program?
    12·1 answer
  • HELP ME PLEASE 41 PTS
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!