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]
3 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]3 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
PHP is based on C rather than ______.
Maksim231197 [3]

Answer:

2b2t

Explanation:

2b2t

8 0
3 years ago
Nathan took a picture of his friends while they were on a field trip. He wants upload this picture to a photo-sharing site. He w
Alenkinab [10]

Answer:

photoshop

Explanation:

(if there are answer choices pls comment them and  I'll pick an answer from them, but this is just my best guess. : )

5 0
3 years ago
It can be hard to get close enough to photograph animals in the wild true or false
marysya [2.9K]

Answer:

True

Explanation:

8 0
3 years ago
Read 2 more answers
________ is the process of translating a task into a series of commands that a computer will use to perform the task.
IgorC [24]
Programming 
It can also be described as Reverse Engineering 
7 0
3 years ago
Which of the following statements are true about the Internet?
Arlecino [84]
1, 2, and 3 are true
6 0
3 years ago
Other questions:
  • The illustrations group contains all but a _______​
    9·1 answer
  • True / False<br> Registers are generally optimized for capacity instead of speed.
    14·1 answer
  • Changing the position of the wing will
    9·1 answer
  • Here's a thought: Why does your Brainly ranking keep going down?
    6·2 answers
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • The number of pixels displayed on the screen is known as ________.
    13·1 answer
  • Write down the characterizations that best suits the term Java applets?
    7·1 answer
  • 3. Special keys labelled Fl to F12.
    8·1 answer
  • GRAND THEFT AUTO 5 LOLLL
    15·2 answers
  • What were the names of Henry VIII's six wives?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!