Question: solve in c + + Question 2 Given an n m matrix, a , where each a ( i , j ) is the value

solve in c++
Question 2
Given an nm matrix, a, where each a(i,j) is the value of the cell at the intersection of row i and column j, create another nm matrix, b, using the following algorithm to set the values of each b(x,y) with zerobased indexing:
s=
for
for
s=s+a(i,j)
}
}
b(x,y)=s
Note that the algorithm sets just one b(x,y) per execution and that 0y
If matrix ais:
123
456
The following operations are performed:
Element
Values
b(,0)
1
b(0,1)
1+2
b(0,2)
a(0,0)+a(0,1)+a(0,2)
a(0,0)
b(x,y)
1
6
b(1,0)
a(0,0)+a(1,0)
1+4
5
b(1,1)
1+2+4+5
b(1,2)
1
a(0,0)+a(0,1)
3
2
3
a(0,0)+a(0,1)+a(0,2)1+2+3+4+5+6,
1+2+3+4+5+6,21
+a(1,0)+a(1,1)+a(1,2)
a(0,0)+a(0,1)
12
+a(1,0)+a(1;1)
1+2+3
136
5,12,21
Function Description
ALL. Complete the function findMatrix in the editor below.
findMatrix has the following parameter(s): int a[n][m]: a2-dimensional array of
1 integers
Returns:
2 int [n][m] : the calculated 2-dimensional array of integers denoting b
3
Constraints
1n,m103
0a(i,j)103, where 2n=22a[]m=20j.
Input Format for Custom Testing
Sample Case 0
Sample Input
STDIN Function
2 number of rows ina[]
n=2
2 number of columns in
a[]m=2
120i and 0j.
Input Format for Custom Testing
Sample Case 0
Sample Input
STDIN Function
2 number of rows ina[]
n=2
2 number of columns in
a[]m=2
12
 solve in c++ Question 2 Given an nm matrix, a, where

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!