Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Will upvote if correct In this problem, you will declare and define the function LargestVectorSum in the header file solution.hpp and source file solution.cc respectively,
Will upvote if correct In this problem, you will declare and define the function LargestVectorSum in the header file solution.hpp and source file solution.cc respectively, using the C conventions introduced in the daily lessons. Your LargestVectorSum function must be defined with single parameter, a twodimensional std::vector of ints. LargestVectorSum will return an object typed LargestSumpair. We provide the definition of this structured type in largestsumpair.hpp; do not change that definition. Now that the return type and signature of LargestVectorsum has been specified, let's discuss what this function is to do and how the returned object is to be composed. LargestVectorSum will examine the twodimensional vector of integers passed to it rowbyrow. Your function will track the index of the row whose contents sum to the largest most positive integer value and record what that sum was. Keep in mind, that a vector's row may have positive and negative values. Do not assume that the rows contain an equal number of columns: the number of columns in one row can and will differ from one another. If more than one row sums to the same value, and that value is the largest sum, record the row with the smaller index. What does smaller index mean? Given a twodimensional vector indexed as vect.atrow atcol we mean the row with a smaller value of row. Once you're finished examining the two dimensional vector, create a new LargestSumPair object, initializing the data member index with the index of the row whose contents sum to the largest most positive integer value and sum with the sum calculated for that row. Assume the vector passed to your function will have at least one row.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started