Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ 3 41 42 43 44 45 So the value at row:2, column:3 is 34 (rows and columns both start at 0) However, there is
c++
3 41 42 43 44 45 So the value at row:2, column:3 is 34 (rows and columns both start at 0) However, there is a fairly easy way to translate between a 2D vector as shown above and a ID vector. Below is a 1D vector representation of the matrix above with the 1D indicies in bold. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 The question is really, how to translate row:2, column:3 to a 1D vector index and how to translate a ID vector index back to a row/column format. To do this we have to know the number of columns in the 2D vector. In this particular case, 5 columns. row-index/5 (integer division), where 5 is the number of columns. column index%5 (modulus), where 5 is the number of columns index- row 5+column, where 5 is the number of columns For the example, row: 2 column: 3 is index (2 * 5) + 3 13 index 13 is row-13/5 2. column 13%5 3 Program Specifications Each of the functions below is doing calculations on a 2D vector using a 1D vector as the underlying parameter that is passed. The parameters are passed as const references: references to prevent copying but const to prevent modification of the parameter function: ostreams print_vector (const vectorStep 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